mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Merge topic 'device-resource-management'
fe3b82b99 implement return codes and protected virtual parsing of arguments ce9c27bc0 Implement tests for RuntimeDeviceConfiguration helpers 408beefc0 Implement RuntimeDeviceConfiguration Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <morelandkd@ornl.gov> Merge-request: !2513
This commit is contained in:
commit
f949d8adea
@ -146,6 +146,9 @@ set(sources
|
||||
internal/Buffer.cxx
|
||||
internal/DeviceAdapterMemoryManager.cxx
|
||||
internal/DeviceAdapterMemoryManagerShared.cxx
|
||||
internal/RuntimeDeviceConfiguration.cxx
|
||||
internal/RuntimeDeviceConfigurationOptions.cxx
|
||||
internal/RuntimeDeviceOption.cxx
|
||||
Initialize.cxx
|
||||
Logging.cxx
|
||||
RuntimeDeviceTracker.cxx
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
#include <vtkm/cont/internal/OptionParserArguments.h>
|
||||
|
||||
#if defined(VTKM_ENABLE_KOKKOS)
|
||||
#include <vtkm/cont/kokkos/internal/Initialize.h>
|
||||
@ -26,17 +27,7 @@ namespace opt = vtkm::cont::internal::option;
|
||||
namespace
|
||||
{
|
||||
|
||||
enum OptionIndex
|
||||
{
|
||||
UNKNOWN,
|
||||
DEVICE,
|
||||
LOGLEVEL, // not parsed by this parser, but by loguru
|
||||
HELP,
|
||||
DEPRECATED_DEVICE,
|
||||
DEPRECATED_LOGLEVEL
|
||||
};
|
||||
|
||||
struct VtkmArg : public opt::Arg
|
||||
struct VtkmDeviceArg : public opt::Arg
|
||||
{
|
||||
static opt::ArgStatus IsDevice(const opt::Option& option, bool msg)
|
||||
{
|
||||
@ -48,20 +39,21 @@ struct VtkmArg : public opt::Arg
|
||||
VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error,
|
||||
"Missing device after option '"
|
||||
<< std::string(option.name, static_cast<size_t>(option.namelen))
|
||||
<< "'.\nValid devices are: " << VtkmArg::GetValidDeviceNames() << "\n");
|
||||
<< "'.\nValid devices are: " << VtkmDeviceArg::GetValidDeviceNames()
|
||||
<< "\n");
|
||||
}
|
||||
return opt::ARG_ILLEGAL;
|
||||
}
|
||||
|
||||
auto id = vtkm::cont::make_DeviceAdapterId(option.arg);
|
||||
|
||||
if (!VtkmArg::DeviceIsAvailable(id))
|
||||
if (!VtkmDeviceArg::DeviceIsAvailable(id))
|
||||
{
|
||||
VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error,
|
||||
"Unavailable device specificed after option '"
|
||||
<< std::string(option.name, static_cast<size_t>(option.namelen)) << "': '"
|
||||
<< option.arg
|
||||
<< "'.\nValid devices are: " << VtkmArg::GetValidDeviceNames() << "\n");
|
||||
<< option.arg << "'.\nValid devices are: "
|
||||
<< VtkmDeviceArg::GetValidDeviceNames() << "\n");
|
||||
return opt::ARG_ILLEGAL;
|
||||
}
|
||||
|
||||
@ -93,7 +85,6 @@ struct VtkmArg : public opt::Arg
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static std::string GetValidDeviceNames()
|
||||
{
|
||||
std::ostringstream names;
|
||||
@ -102,66 +93,16 @@ struct VtkmArg : public opt::Arg
|
||||
for (vtkm::Int8 i = 0; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
auto id = vtkm::cont::make_DeviceAdapterId(i);
|
||||
if (VtkmArg::DeviceIsAvailable(id))
|
||||
if (VtkmDeviceArg::DeviceIsAvailable(id))
|
||||
{
|
||||
names << "\"" << id.GetName() << "\" ";
|
||||
}
|
||||
}
|
||||
return names.str();
|
||||
}
|
||||
|
||||
static opt::ArgStatus Required(const opt::Option& option, bool msg)
|
||||
{
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error,
|
||||
"Missing argument after option '"
|
||||
<< std::string(option.name, static_cast<size_t>(option.namelen))
|
||||
<< "'.\n");
|
||||
}
|
||||
return opt::ARG_ILLEGAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Method used for guessing whether an option that do not support (perhaps that calling
|
||||
// program knows about it) has an option attached to it (which should also be ignored).
|
||||
static opt::ArgStatus UnknownOption(const opt::Option& option, bool msg)
|
||||
{
|
||||
// If we don't have an arg, obviously we don't have an arg.
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
return opt::ARG_NONE;
|
||||
}
|
||||
|
||||
// The opt::Arg::Optional method will return that the ARG is OK if and only if
|
||||
// the argument is attached to the option (e.g. --foo=bar). If that is the case,
|
||||
// then we definitely want to report that the argument is OK.
|
||||
if (opt::Arg::Optional(option, msg) == opt::ARG_OK)
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
|
||||
// Now things get tricky. Maybe the next argument is an option or maybe it is an
|
||||
// argument for this option. We will guess that if the next argument does not
|
||||
// look like an option, we will treat it as such.
|
||||
if (option.arg[0] == '-')
|
||||
{
|
||||
return opt::ARG_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // end anon namespace
|
||||
} // namespace
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -187,7 +128,9 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
vtkm::cont::InitLogging(argc, argv, loggingFlag);
|
||||
}
|
||||
|
||||
|
||||
#ifdef VTKM_ENABLE_KOKKOS
|
||||
// TODO: remove this once runtime config updates are completely implemented
|
||||
vtkm::cont::kokkos::internal::Initialize(argc, argv);
|
||||
#endif
|
||||
|
||||
@ -195,41 +138,53 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
std::vector<opt::Descriptor> usage;
|
||||
if ((opts & InitializeOptions::AddHelp) != InitializeOptions::None)
|
||||
{
|
||||
usage.push_back({ UNKNOWN, 0, "", "", VtkmArg::UnknownOption, "Usage information:\n" });
|
||||
}
|
||||
usage.push_back(
|
||||
{ DEVICE,
|
||||
0,
|
||||
"",
|
||||
"vtkm-device",
|
||||
VtkmArg::IsDevice,
|
||||
" --vtkm-device <dev> \tForce device to dev. Omit device to list available devices." });
|
||||
usage.push_back({ DEPRECATED_DEVICE,
|
||||
0,
|
||||
"d",
|
||||
"device",
|
||||
VtkmArg::IsDevice,
|
||||
" --device, -d <dev> \tDEPRECATED: use --vtkm-device to set the device" });
|
||||
usage.push_back(
|
||||
{ LOGLEVEL, 0, "", loggingFlagName.c_str(), VtkmArg::Required, loggingHelp.c_str() });
|
||||
usage.push_back({ DEPRECATED_LOGLEVEL,
|
||||
0,
|
||||
"v",
|
||||
"",
|
||||
VtkmArg::Required,
|
||||
" -v <#|INFO|WARNING|ERROR|FATAL|OFF> \tDEPRECATED: use --vtkm-log-level to "
|
||||
"set the log level" });
|
||||
if ((opts & InitializeOptions::AddHelp) != InitializeOptions::None)
|
||||
{
|
||||
usage.push_back({ HELP,
|
||||
usage.push_back({ opt::OptionIndex::UNKNOWN,
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
opt::VtkmArg::UnknownOption,
|
||||
"Usage information:\n" });
|
||||
usage.push_back({ opt::OptionIndex::HELP,
|
||||
0,
|
||||
"h",
|
||||
"vtkm-help",
|
||||
opt::Arg::None,
|
||||
" --vtkm-help, -h \tPrint usage information." });
|
||||
}
|
||||
usage.push_back(
|
||||
{ opt::OptionIndex::DEVICE,
|
||||
0,
|
||||
"",
|
||||
"vtkm-device",
|
||||
VtkmDeviceArg::IsDevice,
|
||||
" --vtkm-device <dev> \tForce device to dev. Omit device to list available devices." });
|
||||
usage.push_back({ opt::OptionIndex::LOGLEVEL,
|
||||
0,
|
||||
"",
|
||||
loggingFlagName.c_str(),
|
||||
opt::VtkmArg::Required,
|
||||
loggingHelp.c_str() });
|
||||
|
||||
// TODO: remove deprecated options on next vtk-m release
|
||||
usage.push_back({ opt::OptionIndex::DEPRECATED_DEVICE,
|
||||
0,
|
||||
"d",
|
||||
"device",
|
||||
VtkmDeviceArg::IsDevice,
|
||||
" --device, -d <dev> \tDEPRECATED: use --vtkm-device to set the device" });
|
||||
usage.push_back({ opt::OptionIndex::DEPRECATED_LOGLEVEL,
|
||||
0,
|
||||
"v",
|
||||
"",
|
||||
opt::VtkmArg::Required,
|
||||
" -v <#|INFO|WARNING|ERROR|FATAL|OFF> \tDEPRECATED: use --vtkm-log-level to "
|
||||
"set the log level" });
|
||||
|
||||
// Bring in extra args used by the runtime device configuration options
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationOptions runtimeDeviceOptions(usage);
|
||||
|
||||
// Required to collect unknown arguments when help is off.
|
||||
usage.push_back({ UNKNOWN, 0, "", "", VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ opt::OptionIndex::UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
{
|
||||
@ -255,38 +210,38 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (options[HELP])
|
||||
if (options[opt::OptionIndex::HELP])
|
||||
{
|
||||
std::cerr << config.Usage;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (options[DEPRECATED_LOGLEVEL])
|
||||
if (options[opt::OptionIndex::DEPRECATED_LOGLEVEL])
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Supplied Deprecated log level flag: "
|
||||
<< std::string{ options[DEPRECATED_LOGLEVEL].name } << ", use " << loggingFlag
|
||||
<< " instead.");
|
||||
<< std::string{ options[opt::OptionIndex::DEPRECATED_LOGLEVEL].name } << ", use "
|
||||
<< loggingFlag << " instead.");
|
||||
#ifdef VTKM_ENABLE_LOGGING
|
||||
loguru::g_stderr_verbosity =
|
||||
loguru::get_verbosity_from_name(options[DEPRECATED_LOGLEVEL].arg);
|
||||
loguru::get_verbosity_from_name(options[opt::OptionIndex::DEPRECATED_LOGLEVEL].arg);
|
||||
#endif // VTKM_ENABLE_LOGGING
|
||||
}
|
||||
|
||||
if (options[DEVICE] || options[DEPRECATED_DEVICE])
|
||||
if (options[opt::OptionIndex::DEVICE] || options[opt::OptionIndex::DEPRECATED_DEVICE])
|
||||
{
|
||||
const char* arg = nullptr;
|
||||
if (options[DEPRECATED_DEVICE])
|
||||
if (options[opt::OptionIndex::DEPRECATED_DEVICE])
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Supplied Deprecated device flag "
|
||||
<< std::string{ options[DEPRECATED_DEVICE].name }
|
||||
<< std::string{ options[opt::OptionIndex::DEPRECATED_DEVICE].name }
|
||||
<< ", use --vtkm-device instead");
|
||||
arg = options[DEPRECATED_DEVICE].arg;
|
||||
arg = options[opt::OptionIndex::DEPRECATED_DEVICE].arg;
|
||||
}
|
||||
if (options[DEVICE])
|
||||
if (options[opt::OptionIndex::DEVICE])
|
||||
{
|
||||
arg = options[DEVICE].arg;
|
||||
arg = options[opt::OptionIndex::DEVICE].arg;
|
||||
}
|
||||
auto id = vtkm::cont::make_DeviceAdapterId(arg);
|
||||
if (id != vtkm::cont::DeviceAdapterTagAny{})
|
||||
@ -306,9 +261,9 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
}
|
||||
else if ((opts & InitializeOptions::RequireDevice) != InitializeOptions::None)
|
||||
{
|
||||
auto devices = VtkmArg::GetValidDeviceNames();
|
||||
auto devices = VtkmDeviceArg::GetValidDeviceNames();
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error, "Device not given on command line.");
|
||||
std::cerr << "Target device must be specified via -d or --device.\n"
|
||||
std::cerr << "Target device must be specified via --vtkm-device.\n"
|
||||
"Valid devices: "
|
||||
<< devices << std::endl;
|
||||
if ((opts & InitializeOptions::AddHelp) != InitializeOptions::None)
|
||||
@ -318,7 +273,9 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (const opt::Option* opt = options[UNKNOWN]; opt != nullptr; opt = opt->next())
|
||||
|
||||
for (const opt::Option* opt = options[opt::OptionIndex::UNKNOWN]; opt != nullptr;
|
||||
opt = opt->next())
|
||||
{
|
||||
if ((opts & InitializeOptions::ErrorOnBadOption) != InitializeOptions::None)
|
||||
{
|
||||
@ -359,7 +316,8 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
{
|
||||
copyArg = true;
|
||||
}
|
||||
for (const opt::Option* opt = options[UNKNOWN]; !copyArg && opt != nullptr; opt = opt->next())
|
||||
for (const opt::Option* opt = options[opt::OptionIndex::UNKNOWN]; !copyArg && opt != nullptr;
|
||||
opt = opt->next())
|
||||
{
|
||||
if (thisArg == opt->name)
|
||||
{
|
||||
@ -392,6 +350,12 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
}
|
||||
}
|
||||
argc = destArg;
|
||||
|
||||
{
|
||||
runtimeDeviceOptions.Initialize(options.get());
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
runtimeDevice.GetRuntimeConfiguration(config.Device, runtimeDeviceOptions, argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <vtkm/cont/DeviceAdapterList.h>
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
#include <vtkm/cont/ErrorBadDevice.h>
|
||||
#include <vtkm/cont/Logging.h>
|
||||
|
||||
//Bring in each device adapters runtime class
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterRuntimeDetectorCuda.h>
|
||||
@ -79,6 +80,57 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class RuntimeDeviceConfigurationInvalid
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
public:
|
||||
VTKM_CONT virtual ~RuntimeDeviceConfigurationInvalid() override final {}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagUndefined{};
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode SetThreads(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice("Tried to set the number of threads on an invalid device");
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode SetNumaRegions(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice(
|
||||
"Tried to set the number of numa regions on an invalid device");
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode SetDeviceInstance(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice("Tried to set the device instance on an invalid device");
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode GetThreads(
|
||||
vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice("Tried to get the number of threads on an invalid device");
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode GetNumaRegions(
|
||||
vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice(
|
||||
"Tried to get the number of numa regions on an invalid device");
|
||||
}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::internal::RuntimeDeviceConfigReturnCode GetDeviceInstance(
|
||||
vtkm::Id&) const override final
|
||||
{
|
||||
throw vtkm::cont::ErrorBadDevice("Tried to get the device instance on an invalid device");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct VTKM_NEVER_EXPORT InitializeDeviceNames
|
||||
{
|
||||
vtkm::cont::DeviceAdapterNameType* Names;
|
||||
@ -149,6 +201,54 @@ struct VTKM_NEVER_EXPORT InitializeDeviceMemoryManagers
|
||||
}
|
||||
};
|
||||
|
||||
struct VTKM_NEVER_EXPORT InitializeRuntimeDeviceConfigurations
|
||||
{
|
||||
std::unique_ptr<vtkm::cont::internal::RuntimeDeviceConfigurationBase>* RuntimeConfigurations;
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationOptions RuntimeConfigurationOptions;
|
||||
|
||||
VTKM_CONT
|
||||
InitializeRuntimeDeviceConfigurations(
|
||||
std::unique_ptr<vtkm::cont::internal::RuntimeDeviceConfigurationBase>* runtimeConfigurations,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions)
|
||||
: RuntimeConfigurations(runtimeConfigurations)
|
||||
, RuntimeConfigurationOptions(configOptions)
|
||||
{
|
||||
if (!configOptions.IsInitialized())
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
||||
"Initializing 'RuntimeDeviceConfigurations' with uninitialized configOptions. Did "
|
||||
"you call vtkm::cont::Initialize?");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT void CreateRuntimeConfiguration(Device device, int& argc, char* argv[], std::true_type)
|
||||
{
|
||||
auto id = device.GetValue();
|
||||
|
||||
if (id > 0 && id < VTKM_MAX_DEVICE_ADAPTER_ID)
|
||||
{
|
||||
this->RuntimeConfigurations[id].reset(
|
||||
new vtkm::cont::internal::RuntimeDeviceConfiguration<Device>);
|
||||
this->RuntimeConfigurations[id]->Initialize(RuntimeConfigurationOptions, argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT void CreateRuntimeConfiguration(Device, int&, char**, std::false_type)
|
||||
{
|
||||
// No runtime configuration for invalid devices.
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT void operator()(Device device, int& argc, char* argv[])
|
||||
{
|
||||
this->CreateRuntimeConfiguration(
|
||||
device, argc, argv, std::integral_constant<bool, device.IsEnabled>{});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct VTKM_NEVER_EXPORT RuntimeDeviceInformationFunctor
|
||||
{
|
||||
bool Exists = false;
|
||||
@ -239,7 +339,61 @@ private:
|
||||
DeviceMemoryManagers[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||
DeviceAdapterMemoryManagerInvalid InvalidManager;
|
||||
};
|
||||
}
|
||||
|
||||
class RuntimeDeviceConfigurations
|
||||
{
|
||||
public:
|
||||
static vtkm::cont::internal::RuntimeDeviceConfigurationBase& GetRuntimeDeviceConfiguration(
|
||||
vtkm::cont::DeviceAdapterId device,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[])
|
||||
{
|
||||
const auto id = device.GetValue();
|
||||
if (device.IsValueValid())
|
||||
{
|
||||
auto&& runtimeConfiguration = Instance(configOptions, argc, argv).DeviceConfigurations[id];
|
||||
if (runtimeConfiguration)
|
||||
{
|
||||
return *runtimeConfiguration.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Instance(configOptions, argc, argv).InvalidConfiguration;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Instance(configOptions, argc, argv).InvalidConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static RuntimeDeviceConfigurations& Instance(
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[])
|
||||
{
|
||||
static RuntimeDeviceConfigurations instance{ configOptions, argc, argv };
|
||||
return instance;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigurations(
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions configOptions,
|
||||
int& argc,
|
||||
char* argv[])
|
||||
{
|
||||
InitializeRuntimeDeviceConfigurations functor(this->DeviceConfigurations, configOptions);
|
||||
vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST(), argc, argv);
|
||||
}
|
||||
|
||||
friend struct InitializeRuntimeDeviceConfigurations;
|
||||
|
||||
std::unique_ptr<vtkm::cont::internal::RuntimeDeviceConfigurationBase>
|
||||
DeviceConfigurations[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||
RuntimeDeviceConfigurationInvalid InvalidConfiguration;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -326,8 +480,38 @@ RuntimeDeviceInformation::GetMemoryManager(DeviceAdapterId device) const
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Attempted to get a DeviceAdapterMemoryManager for an invalid device.");
|
||||
"Attempted to get a DeviceAdapterMemoryManager for an invalid device '" + device.GetName() +
|
||||
"'");
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT vtkm::cont::internal::RuntimeDeviceConfigurationBase&
|
||||
RuntimeDeviceInformation::GetRuntimeConfiguration(
|
||||
DeviceAdapterId device,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[]) const
|
||||
{
|
||||
return RuntimeDeviceConfigurations::GetRuntimeDeviceConfiguration(
|
||||
device, configOptions, argc, argv);
|
||||
}
|
||||
|
||||
VTKM_CONT vtkm::cont::internal::RuntimeDeviceConfigurationBase&
|
||||
RuntimeDeviceInformation::GetRuntimeConfiguration(
|
||||
DeviceAdapterId device,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions) const
|
||||
{
|
||||
int placeholder;
|
||||
return this->GetRuntimeConfiguration(device, configOptions, placeholder, nullptr);
|
||||
}
|
||||
|
||||
VTKM_CONT vtkm::cont::internal::RuntimeDeviceConfigurationBase&
|
||||
RuntimeDeviceInformation::GetRuntimeConfiguration(DeviceAdapterId device) const
|
||||
{
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationOptions placeholder;
|
||||
return this->GetRuntimeConfiguration(device, placeholder);
|
||||
}
|
||||
|
||||
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterMemoryManager.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm
|
||||
@ -53,8 +54,42 @@ public:
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::cont::internal::DeviceAdapterMemoryManagerBase& GetMemoryManager(DeviceAdapterId id) const;
|
||||
|
||||
/// Returns a reference to a `RuntimeDeviceConfiguration` that will work with the
|
||||
/// given device. If the device in question is not valid, a placeholder
|
||||
/// `InvalidRuntimeDeviceConfiguration` will be returned. Attempting to
|
||||
/// call any of the methods of this object will result in a runtime exception.
|
||||
/// The fully loaded version of this method is automatically called at the end
|
||||
/// of `vkmt::cont::Initialize` which performs automated setup of all runtime
|
||||
/// devices using parsed vtkm arguments.
|
||||
///
|
||||
/// params:
|
||||
/// id - The specific device to retreive the RuntimeDeviceConfiguration options for
|
||||
/// configOptions - VTKm provided options that should be included when initializing
|
||||
/// a given RuntimeDeviceConfiguration
|
||||
/// argc - The number of command line arguments to parse when Initializing
|
||||
/// a given RuntimeDeviceConfiguration
|
||||
/// argv - The extra command line arguments to parse when Initializing a given
|
||||
/// RuntimeDeviceConfiguration. This argument is mainlued used in conjuction
|
||||
/// with Kokkos config arg parsing to include specific --kokkos command
|
||||
/// line flags and environment variables.
|
||||
VTKM_CONT
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationBase& GetRuntimeConfiguration(
|
||||
DeviceAdapterId id,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[] = nullptr) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationBase& GetRuntimeConfiguration(
|
||||
DeviceAdapterId id,
|
||||
const vtkm::cont::internal::RuntimeDeviceConfigurationOptions& configOptions) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::internal::RuntimeDeviceConfigurationBase& GetRuntimeConfiguration(
|
||||
DeviceAdapterId id) const;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_RuntimeDeviceInformation_h
|
||||
|
@ -226,4 +226,4 @@ vtkm::cont::RuntimeDeviceTracker& GetRuntimeDeviceTracker();
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif //vtk_m_filter_RuntimeDeviceTracker_h
|
||||
#endif //vtk_m_cont_RuntimeDeviceTracker_h
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterAlgorithmCuda.h>
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterMemoryManagerCuda.h>
|
||||
#include <vtkm/cont/cuda/internal/RuntimeDeviceConfigurationCuda.h>
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
#include <vtkm/cont/cuda/internal/VirtualObjectTransferCuda.h>
|
||||
#endif //VTKM_NO_DEPRECATED_VIRTUAL
|
||||
|
@ -16,6 +16,7 @@ set(headers
|
||||
DeviceAdapterTagCuda.h
|
||||
DeviceAdapterTimerImplementationCuda.h
|
||||
MakeThrustIterator.h
|
||||
RuntimeDeviceConfigurationCuda.h
|
||||
ScopedCudaStackSize.h
|
||||
ThrustExceptionHandler.h
|
||||
)
|
||||
|
49
vtkm/cont/cuda/internal/RuntimeDeviceConfigurationCuda.h
Normal file
49
vtkm/cont/cuda/internal/RuntimeDeviceConfigurationCuda.h
Normal file
@ -0,0 +1,49 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
||||
#define vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
||||
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagCuda>
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagCuda{};
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetDeviceInstance(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: set the cuda device instance
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetDeviceInstance(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Get the cuda device instance (also maybe a list of available devices?)
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
};
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
@ -27,10 +27,14 @@ set(headers
|
||||
IteratorFromArrayPortal.h
|
||||
KXSort.h
|
||||
OptionParser.h
|
||||
OptionParserArguments.h
|
||||
ParallelRadixSort.h
|
||||
ParallelRadixSortInterface.h
|
||||
PointLocatorBase.h
|
||||
ReverseConnectivityBuilder.h
|
||||
RuntimeDeviceConfiguration.h
|
||||
RuntimeDeviceConfigurationOptions.h
|
||||
RuntimeDeviceOption.h
|
||||
StorageDeprecated.h
|
||||
StorageError.h
|
||||
Variant.h
|
||||
|
@ -32,6 +32,7 @@ namespace cont
|
||||
namespace internal
|
||||
{
|
||||
|
||||
|
||||
// Check to make sure that optionparser.h has not been included before. If it has, remove its
|
||||
// header guard so we can include it again under our namespace.
|
||||
#ifdef OPTIONPARSER_H_
|
||||
@ -53,9 +54,10 @@ namespace internal
|
||||
// Remove the header guard for other inclusion.
|
||||
#undef OPTIONPARSER_H_
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
VTKM_THIRDPARTY_POST_INCLUDE
|
||||
|
||||
|
104
vtkm/cont/internal/OptionParserArguments.h
Normal file
104
vtkm/cont/internal/OptionParserArguments.h
Normal file
@ -0,0 +1,104 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_internal_OptionParserArguments_h
|
||||
#define vtk_m_cont_internal_OptionParserArguments_h
|
||||
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace option
|
||||
{
|
||||
|
||||
/// All options supported by the parser are stored here for usage in multiple modules
|
||||
enum OptionIndex
|
||||
{
|
||||
// special option for dealing with unknown arguments
|
||||
UNKNOWN,
|
||||
|
||||
// general vtkm arguments
|
||||
HELP,
|
||||
DEVICE,
|
||||
LOGLEVEL, // not parsed by this parser, but by loguru
|
||||
|
||||
// TODO: remove deprecated arguments on next vtk-m release
|
||||
DEPRECATED_DEVICE,
|
||||
DEPRECATED_LOGLEVEL,
|
||||
|
||||
// All RuntimeDeviceConfiguration specific options
|
||||
NUM_THREADS,
|
||||
NUMA_REGIONS,
|
||||
DEVICE_INSTANCE
|
||||
};
|
||||
|
||||
struct VtkmArg : public option::Arg
|
||||
{
|
||||
static option::ArgStatus Required(const option::Option& option, bool msg)
|
||||
{
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error,
|
||||
"Missing argument after option '"
|
||||
<< std::string(option.name, static_cast<size_t>(option.namelen))
|
||||
<< "'.\n");
|
||||
}
|
||||
return option::ARG_ILLEGAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return option::ARG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Method used for guessing whether an option that do not support (perhaps that calling
|
||||
// program knows about it) has an option attached to it (which should also be ignored).
|
||||
static option::ArgStatus UnknownOption(const option::Option& option, bool msg)
|
||||
{
|
||||
// If we don't have an arg, obviously we don't have an arg.
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
return option::ARG_NONE;
|
||||
}
|
||||
|
||||
// The option::Arg::Optional method will return that the ARG is OK if and only if
|
||||
// the argument is attached to the option (e.g. --foo=bar). If that is the case,
|
||||
// then we definitely want to report that the argument is OK.
|
||||
if (option::Arg::Optional(option, msg) == option::ARG_OK)
|
||||
{
|
||||
return option::ARG_OK;
|
||||
}
|
||||
|
||||
// Now things get tricky. Maybe the next argument is an option or maybe it is an
|
||||
// argument for this option. We will guess that if the next argument does not
|
||||
// look like an option, we will treat it as such.
|
||||
if (option.arg[0] == '-')
|
||||
{
|
||||
return option::ARG_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return option::ARG_OK;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace vtkm::cont::internal::option
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_cont_internal_OptionParserArguments_h
|
115
vtkm/cont/internal/RuntimeDeviceConfiguration.cxx
Normal file
115
vtkm/cont/internal/RuntimeDeviceConfiguration.cxx
Normal file
@ -0,0 +1,115 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
RuntimeDeviceConfigurationBase::~RuntimeDeviceConfigurationBase() noexcept = default;
|
||||
|
||||
void RuntimeDeviceConfigurationBase::Initialize(
|
||||
const RuntimeDeviceConfigurationOptions& configOptions) const
|
||||
{
|
||||
if (configOptions.VTKmNumThreads.IsSet())
|
||||
{
|
||||
auto value = configOptions.VTKmNumThreads.GetValue();
|
||||
auto code = this->SetThreads(value);
|
||||
this->LogReturnCode(code, "SetThreads", value);
|
||||
}
|
||||
if (configOptions.VTKmNumaRegions.IsSet())
|
||||
{
|
||||
auto value = configOptions.VTKmNumaRegions.GetValue();
|
||||
auto code = this->SetNumaRegions(value);
|
||||
this->LogReturnCode(code, "SetNumaRegions", value);
|
||||
}
|
||||
if (configOptions.VTKmDeviceInstance.IsSet())
|
||||
{
|
||||
auto value = configOptions.VTKmDeviceInstance.GetValue();
|
||||
auto code = this->SetDeviceInstance(value);
|
||||
this->LogReturnCode(code, "SetDeviceInstance", value);
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeDeviceConfigurationBase::Initialize(
|
||||
const RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[]) const
|
||||
{
|
||||
this->ParseExtraArguments(argc, argv);
|
||||
this->Initialize(configOptions);
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::SetThreads(const vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::SetNumaRegions(const vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::SetDeviceInstance(
|
||||
const vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::GetThreads(vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::GetNumaRegions(vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigReturnCode RuntimeDeviceConfigurationBase::GetDeviceInstance(vtkm::Id&) const
|
||||
{
|
||||
return RuntimeDeviceConfigReturnCode::INVALID_FOR_DEVICE;
|
||||
}
|
||||
|
||||
void RuntimeDeviceConfigurationBase::ParseExtraArguments(int&, char*[]) const {}
|
||||
|
||||
void RuntimeDeviceConfigurationBase::LogReturnCode(const RuntimeDeviceConfigReturnCode& code,
|
||||
const std::string& function,
|
||||
const vtkm::Id& value) const
|
||||
{
|
||||
// Note that we intentionally are not logging a warning for INVALID_FOR_DEVICE. When a
|
||||
// user provides a command line argument, it gets sent to all possible devices during
|
||||
// `Initialize` regardless of whether it is used. The user does not need a lot of
|
||||
// useless warnings about (for example) the serial device not supporting parameters
|
||||
// intended for a real parallel device.
|
||||
if (code == RuntimeDeviceConfigReturnCode::OUT_OF_BOUNDS)
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
||||
function << " for " << this->GetDevice().GetName()
|
||||
<< "was OUT_OF_BOUNDS with value: " << value);
|
||||
}
|
||||
else if (code == RuntimeDeviceConfigReturnCode::INVALID_VALUE)
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
||||
function << "for " << this->GetDevice().GetName()
|
||||
<< "had INVLAID_VALUE for value: " << value);
|
||||
}
|
||||
#ifndef VTKM_ENABLE_LOGGING
|
||||
(void)function;
|
||||
(void)value;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
88
vtkm/cont/internal/RuntimeDeviceConfiguration.h
Normal file
88
vtkm/cont/internal/RuntimeDeviceConfiguration.h
Normal file
@ -0,0 +1,88 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_internal_RuntimeDeviceConfiguration_h
|
||||
#define vtk_m_cont_internal_RuntimeDeviceConfiguration_h
|
||||
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfigurationOptions.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
enum class RuntimeDeviceConfigReturnCode
|
||||
{
|
||||
SUCCESS,
|
||||
OUT_OF_BOUNDS,
|
||||
INVALID_FOR_DEVICE,
|
||||
INVALID_VALUE
|
||||
};
|
||||
|
||||
class VTKM_CONT_EXPORT RuntimeDeviceConfigurationBase
|
||||
{
|
||||
public:
|
||||
VTKM_CONT virtual ~RuntimeDeviceConfigurationBase() noexcept;
|
||||
VTKM_CONT virtual vtkm::cont::DeviceAdapterId GetDevice() const = 0;
|
||||
|
||||
/// Calls the various `Set*` methods in this class with the provided set of config
|
||||
/// options which can either be manually provided or automatically initialized
|
||||
/// from command line arguments and environment variables via vtkm::cont::Initialize.
|
||||
/// Each `Set*` method is called only if the corresponding vtk-m option is set, and a
|
||||
/// warning is logged based on the value of the `RuntimeDeviceConfigReturnCode` returned
|
||||
/// via the `Set*` method.
|
||||
VTKM_CONT void Initialize(const RuntimeDeviceConfigurationOptions& configOptions) const;
|
||||
VTKM_CONT void Initialize(const RuntimeDeviceConfigurationOptions& configOptions,
|
||||
int& argc,
|
||||
char* argv[]) const;
|
||||
|
||||
/// The following public methods should be overriden in each individual device.
|
||||
/// A method should return INVALID_FOR_DEVICE if the overriden device does not
|
||||
/// support the particular set method.
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(const vtkm::Id&) const;
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetNumaRegions(const vtkm::Id&) const;
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetDeviceInstance(const vtkm::Id&) const;
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(vtkm::Id& value) const;
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetNumaRegions(vtkm::Id& value) const;
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetDeviceInstance(vtkm::Id& value) const;
|
||||
|
||||
protected:
|
||||
/// An overriden method that can be used to perform extra command line argument parsing
|
||||
/// for cases where a specific device may use additional command line arguments. At the
|
||||
/// moment Kokkos is the only device that overrides this method.
|
||||
VTKM_CONT virtual void ParseExtraArguments(int&, char*[]) const;
|
||||
|
||||
/// Used during Initialize to log a warning message dependent on the return code when
|
||||
/// calling a specific `Set*` method.
|
||||
///
|
||||
/// params:
|
||||
/// code - The code to log a message for
|
||||
/// function - The name of the `Set*` function the code was returned from
|
||||
/// value - The value used as the argument to the `Set*` call.
|
||||
VTKM_CONT virtual void LogReturnCode(const RuntimeDeviceConfigReturnCode& code,
|
||||
const std::string& function,
|
||||
const vtkm::Id& value) const;
|
||||
};
|
||||
|
||||
template <typename DeviceAdapterTag>
|
||||
class RuntimeDeviceConfiguration;
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_cont_internal_RuntimeDeviceConfiguration_h
|
71
vtkm/cont/internal/RuntimeDeviceConfigurationOptions.cxx
Normal file
71
vtkm/cont/internal/RuntimeDeviceConfigurationOptions.cxx
Normal file
@ -0,0 +1,71 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfigurationOptions.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
RuntimeDeviceConfigurationOptions::RuntimeDeviceConfigurationOptions()
|
||||
: VTKmNumThreads(option::OptionIndex::NUM_THREADS, "VTKM_NUM_THREADS")
|
||||
, VTKmNumaRegions(option::OptionIndex::NUMA_REGIONS, "VTKM_NUMA_REGIONS")
|
||||
, VTKmDeviceInstance(option::OptionIndex::DEVICE_INSTANCE, "VTKM_DEVICE_INSTANCE")
|
||||
, Initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
RuntimeDeviceConfigurationOptions::~RuntimeDeviceConfigurationOptions() noexcept = default;
|
||||
|
||||
RuntimeDeviceConfigurationOptions::RuntimeDeviceConfigurationOptions(
|
||||
std::vector<option::Descriptor>& usage)
|
||||
: RuntimeDeviceConfigurationOptions()
|
||||
{
|
||||
usage.push_back(
|
||||
{ option::OptionIndex::NUM_THREADS,
|
||||
0,
|
||||
"",
|
||||
"vtkm-num-threads",
|
||||
option::VtkmArg::Required,
|
||||
" --vtkm-num-threads <dev> \tSets the number of threads to use for the selected device" });
|
||||
usage.push_back(
|
||||
{ option::OptionIndex::NUMA_REGIONS,
|
||||
0,
|
||||
"",
|
||||
"vtkm-numa-regions",
|
||||
option::VtkmArg::Required,
|
||||
" --vtkm-numa-regions <dev> \tSets the number of numa regions when using kokkos/OpenMP" });
|
||||
usage.push_back({ option::OptionIndex::DEVICE_INSTANCE,
|
||||
0,
|
||||
"",
|
||||
"vtkm-device-instance",
|
||||
option::VtkmArg::Required,
|
||||
" --vtkm-device-instance <dev> \tSets the device instance to use when using "
|
||||
"kokkos/cuda" });
|
||||
}
|
||||
|
||||
void RuntimeDeviceConfigurationOptions::Initialize(const option::Option* options)
|
||||
{
|
||||
this->VTKmNumThreads.Initialize(options);
|
||||
this->VTKmNumaRegions.Initialize(options);
|
||||
this->VTKmDeviceInstance.Initialize(options);
|
||||
this->Initialized = true;
|
||||
}
|
||||
|
||||
bool RuntimeDeviceConfigurationOptions::IsInitialized() const
|
||||
{
|
||||
return this->Initialized;
|
||||
}
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
59
vtkm/cont/internal/RuntimeDeviceConfigurationOptions.h
Normal file
59
vtkm/cont/internal/RuntimeDeviceConfigurationOptions.h
Normal file
@ -0,0 +1,59 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_internal_RuntimeDeviceConfigurationOptions_h
|
||||
#define vtk_m_cont_internal_RuntimeDeviceConfigurationOptions_h
|
||||
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
#include <vtkm/cont/internal/OptionParserArguments.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceOption.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// Provides a default set of RuntimeDeviceOptions that vtk-m currently supports setting.
|
||||
/// Each option provided in this class should have a corresponding `Set*` method in the
|
||||
/// RuntimeDeviceConfiguration.
|
||||
class VTKM_CONT_EXPORT RuntimeDeviceConfigurationOptions
|
||||
{
|
||||
public:
|
||||
/// Sets the option indices and environment varaible names for the vtkm supported options.
|
||||
VTKM_CONT RuntimeDeviceConfigurationOptions();
|
||||
|
||||
/// Calls the default constructor and additionally pushes back additional command line
|
||||
/// options to the provided usage vector for integration with the vtkm option parser.
|
||||
VTKM_CONT RuntimeDeviceConfigurationOptions(std::vector<option::Descriptor>& usage);
|
||||
|
||||
VTKM_CONT virtual ~RuntimeDeviceConfigurationOptions() noexcept;
|
||||
|
||||
/// Calls Initialize for each of this class's current configuration options and marks
|
||||
/// the options as initialized.
|
||||
VTKM_CONT void Initialize(const option::Option* options);
|
||||
VTKM_CONT bool IsInitialized() const;
|
||||
|
||||
RuntimeDeviceOption VTKmNumThreads;
|
||||
RuntimeDeviceOption VTKmNumaRegions;
|
||||
RuntimeDeviceOption VTKmDeviceInstance;
|
||||
|
||||
private:
|
||||
bool Initialized;
|
||||
};
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_cont_internal_RuntimeDeviceConfigurationOptions_h
|
110
vtkm/cont/internal/RuntimeDeviceOption.cxx
Normal file
110
vtkm/cont/internal/RuntimeDeviceOption.cxx
Normal file
@ -0,0 +1,110 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/RuntimeDeviceOption.h>
|
||||
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
VTKM_CONT vtkm::Id ParseOption(const std::string& input, const std::string& source)
|
||||
{
|
||||
try
|
||||
{
|
||||
size_t pos;
|
||||
auto value = std::stoi(input, &pos, 10);
|
||||
if (pos != input.size())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Value '" + input + "' from source: '" + source +
|
||||
"' has dangling characters, throwing");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Value '" + input +
|
||||
"' failed to parse as integer from source: '" + source + "'");
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Value '" + input + "' out of range for source: '" + source +
|
||||
"'");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RuntimeDeviceOption::RuntimeDeviceOption(const vtkm::Id& index, const std::string& envName)
|
||||
: Index(index)
|
||||
, EnvName(envName)
|
||||
, Source(RuntimeDeviceOptionSource::NOT_SET)
|
||||
{
|
||||
}
|
||||
|
||||
RuntimeDeviceOption::~RuntimeDeviceOption() noexcept = default;
|
||||
|
||||
void RuntimeDeviceOption::Initialize(const option::Option* options)
|
||||
{
|
||||
this->SetOptionFromEnvironment();
|
||||
this->SetOptionFromOptionsArray(options);
|
||||
}
|
||||
|
||||
void RuntimeDeviceOption::SetOptionFromEnvironment()
|
||||
{
|
||||
if (std::getenv(EnvName.c_str()) != nullptr)
|
||||
{
|
||||
this->Value = ParseOption(std::getenv(EnvName.c_str()), "ENVIRONMENT: " + EnvName);
|
||||
this->Source = RuntimeDeviceOptionSource::ENVIRONMENT;
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeDeviceOption::SetOptionFromOptionsArray(const option::Option* options)
|
||||
{
|
||||
if (options != nullptr && options[this->Index])
|
||||
{
|
||||
this->Value = ParseOption(options[this->Index].arg,
|
||||
"COMMAND_LINE: " + std::string{ options[this->Index].name });
|
||||
this->Source = RuntimeDeviceOptionSource::COMMAND_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeDeviceOption::SetOption(const vtkm::Id& value)
|
||||
{
|
||||
this->Value = value;
|
||||
this->Source = RuntimeDeviceOptionSource::IN_CODE;
|
||||
}
|
||||
|
||||
vtkm::Id RuntimeDeviceOption::GetValue() const
|
||||
{
|
||||
return this->Value;
|
||||
}
|
||||
|
||||
RuntimeDeviceOptionSource RuntimeDeviceOption::GetSource() const
|
||||
{
|
||||
return this->Source;
|
||||
}
|
||||
|
||||
bool RuntimeDeviceOption::IsSet() const
|
||||
{
|
||||
return this->Source != RuntimeDeviceOptionSource::NOT_SET;
|
||||
}
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
74
vtkm/cont/internal/RuntimeDeviceOption.h
Normal file
74
vtkm/cont/internal/RuntimeDeviceOption.h
Normal file
@ -0,0 +1,74 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_internal_RuntimeDeviceOption_h
|
||||
#define vtk_m_cont_internal_RuntimeDeviceOption_h
|
||||
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
#include <vtkm/cont/internal/OptionParserArguments.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
enum class RuntimeDeviceOptionSource
|
||||
{
|
||||
COMMAND_LINE,
|
||||
ENVIRONMENT,
|
||||
IN_CODE,
|
||||
NOT_SET
|
||||
};
|
||||
|
||||
class VTKM_CONT_EXPORT RuntimeDeviceOption
|
||||
{
|
||||
public:
|
||||
/// Constructs a RuntimeDeviceOption, sets the Source to NOT_SET
|
||||
/// params:
|
||||
/// index - index location of this command line argument in an option::Option array
|
||||
/// envName - The environment variable name of this option
|
||||
VTKM_CONT RuntimeDeviceOption(const vtkm::Id& index, const std::string& envName);
|
||||
|
||||
VTKM_CONT virtual ~RuntimeDeviceOption() noexcept;
|
||||
|
||||
/// Initializes this option's value from the environment and then the provided options
|
||||
/// array in that order. The options array is expected to be filled in using the
|
||||
/// vtkm::cont::internal::option::OptionIndex with the usage vector defined in
|
||||
/// vtkm::cont::Initialize.
|
||||
VTKM_CONT void Initialize(const option::Option* options);
|
||||
|
||||
/// Sets the Value to the environment variable of the constructed EnvName
|
||||
VTKM_CONT void SetOptionFromEnvironment();
|
||||
|
||||
/// Grabs and sets the option value using the constructed Index
|
||||
VTKM_CONT void SetOptionFromOptionsArray(const option::Option* options);
|
||||
|
||||
/// Directly set the value for this option
|
||||
VTKM_CONT void SetOption(const vtkm::Id& value);
|
||||
|
||||
VTKM_CONT vtkm::Id GetValue() const;
|
||||
VTKM_CONT RuntimeDeviceOptionSource GetSource() const;
|
||||
VTKM_CONT bool IsSet() const;
|
||||
|
||||
private:
|
||||
const vtkm::Id Index;
|
||||
const std::string EnvName;
|
||||
RuntimeDeviceOptionSource Source;
|
||||
vtkm::Id Value;
|
||||
};
|
||||
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_cont_internal_RuntimeDeviceOption_h
|
@ -12,6 +12,7 @@
|
||||
set(unit_tests
|
||||
UnitTestArrayPortalFromIterators.cxx
|
||||
UnitTestBuffer.cxx
|
||||
UnitTestRuntimeConfigurationOptions.cxx
|
||||
UnitTestIteratorFromArrayPortal.cxx
|
||||
)
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
|
||||
|
@ -0,0 +1,293 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfigurationOptions.h>
|
||||
#include <vtkm/cont/internal/RuntimeDeviceOption.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace internal = vtkm::cont::internal;
|
||||
namespace opt = internal::option;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static std::vector<std::pair<std::string, std::string>> envVars{};
|
||||
|
||||
enum
|
||||
{
|
||||
UNKNOWN,
|
||||
TEST
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
void MakeArgs(int& argc, char**& argv, T&&... args)
|
||||
{
|
||||
constexpr std::size_t numArgs = sizeof...(args);
|
||||
|
||||
std::array<std::string, numArgs> stringArgs = { { args... } };
|
||||
|
||||
// These static variables are declared as static so that the memory will stick around but won't
|
||||
// be reported as a leak.
|
||||
static std::array<std::vector<char>, numArgs> vecArgs;
|
||||
static std::array<char*, numArgs + 1> finalArgs;
|
||||
std::cout << " starting args:";
|
||||
for (std::size_t i = 0; i < numArgs; ++i)
|
||||
{
|
||||
std::cout << " " << stringArgs[i];
|
||||
// Safely copying a C-style string is a PITA
|
||||
vecArgs[i].resize(0);
|
||||
vecArgs[i].reserve(stringArgs[i].size() + 1);
|
||||
for (auto&& c : stringArgs[i])
|
||||
{
|
||||
vecArgs[i].push_back(c);
|
||||
}
|
||||
vecArgs[i].push_back('\0');
|
||||
|
||||
finalArgs[i] = vecArgs[i].data();
|
||||
}
|
||||
finalArgs[numArgs] = nullptr;
|
||||
std::cout << std::endl;
|
||||
|
||||
argc = static_cast<int>(numArgs);
|
||||
argv = finalArgs.data();
|
||||
}
|
||||
|
||||
std::unique_ptr<opt::Option[]> GetOptions(int& argc,
|
||||
char** argv,
|
||||
std::vector<opt::Descriptor>& usage)
|
||||
{
|
||||
if (argc == 0 || argv == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
opt::Stats stats(usage.data(), argc, argv);
|
||||
std::unique_ptr<opt::Option[]> options{ new opt::Option[stats.options_max] };
|
||||
std::unique_ptr<opt::Option[]> buffer{ new opt::Option[stats.buffer_max] };
|
||||
opt::Parser parse(usage.data(), argc, argv, options.get(), buffer.get());
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
void my_setenv(const std::string& var, const std::string& value)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
auto iter = envVars.emplace(envVars.end(), var, value);
|
||||
_putenv_s(iter->first.c_str(), iter->second.c_str());
|
||||
#else
|
||||
setenv(var.c_str(), value.c_str(), 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void my_unsetenv(const std::string& var)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
my_setenv(var, "");
|
||||
#else
|
||||
unsetenv(var.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void TestRuntimeDeviceOptionHappy()
|
||||
{
|
||||
std::vector<opt::Descriptor> usage;
|
||||
usage.push_back({ TEST, 0, "", "test-option", opt::VtkmArg::Required, " --test-option <val>" });
|
||||
usage.push_back({ UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
const std::string env{ "TEST_OPTION" };
|
||||
my_unsetenv(env);
|
||||
|
||||
// Basic no value initialize
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
testOption.Initialize(nullptr);
|
||||
VTKM_TEST_ASSERT(!testOption.IsSet(), "test option should not be set");
|
||||
}
|
||||
|
||||
my_setenv(env, "1");
|
||||
|
||||
// Initialize from environment
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
testOption.Initialize(nullptr);
|
||||
VTKM_TEST_ASSERT(testOption.IsSet(), "Option set through env");
|
||||
VTKM_TEST_ASSERT(testOption.GetSource() == internal::RuntimeDeviceOptionSource::ENVIRONMENT,
|
||||
"Option should be set");
|
||||
VTKM_TEST_ASSERT(testOption.GetValue() == 1, "Option value should be 1");
|
||||
}
|
||||
|
||||
int argc;
|
||||
char** argv;
|
||||
MakeArgs(argc, argv, "--test-option", "2");
|
||||
auto options = GetOptions(argc, argv, usage);
|
||||
VTKM_TEST_ASSERT(options[TEST], "should be and option");
|
||||
|
||||
// Initialize from argument with priority over environment
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
|
||||
testOption.Initialize(options.get());
|
||||
VTKM_TEST_ASSERT(testOption.IsSet(), "Option should be set");
|
||||
VTKM_TEST_ASSERT(testOption.GetSource() == internal::RuntimeDeviceOptionSource::COMMAND_LINE,
|
||||
"Option should be set");
|
||||
VTKM_TEST_ASSERT(testOption.GetValue() == 2, "Option value should be 1");
|
||||
}
|
||||
|
||||
// Initialize then set manually
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
|
||||
testOption.Initialize(options.get());
|
||||
testOption.SetOption(3);
|
||||
VTKM_TEST_ASSERT(testOption.IsSet(), "Option should be set");
|
||||
VTKM_TEST_ASSERT(testOption.GetSource() == internal::RuntimeDeviceOptionSource::IN_CODE,
|
||||
"Option should be set");
|
||||
VTKM_TEST_ASSERT(testOption.GetValue() == 3, "Option value should be 3");
|
||||
}
|
||||
|
||||
my_unsetenv(env);
|
||||
}
|
||||
|
||||
void TestRuntimeDeviceOptionError()
|
||||
{
|
||||
std::vector<opt::Descriptor> usage;
|
||||
usage.push_back({ TEST, 0, "", "test-option", opt::VtkmArg::Required, " --test-option <val>" });
|
||||
usage.push_back({ UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
const std::string env{ "TEST_OPTION" };
|
||||
my_unsetenv(env);
|
||||
|
||||
bool threw = true;
|
||||
|
||||
// Parse a non integer
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
my_setenv(env, "bad");
|
||||
try
|
||||
{
|
||||
testOption.Initialize(nullptr);
|
||||
threw = false;
|
||||
}
|
||||
catch (const vtkm::cont::ErrorBadValue& error)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
error.GetMessage() ==
|
||||
"Value 'bad' failed to parse as integer from source: 'ENVIRONMENT: " + env + "'",
|
||||
"message: " + error.GetMessage());
|
||||
}
|
||||
|
||||
VTKM_TEST_ASSERT(threw, "Should have thrown");
|
||||
}
|
||||
|
||||
// Parse an integer that's too large
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
my_setenv(env, "9938489298493882949384989");
|
||||
try
|
||||
{
|
||||
testOption.Initialize(nullptr);
|
||||
threw = false;
|
||||
}
|
||||
catch (const vtkm::cont::ErrorBadValue& error)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
error.GetMessage() ==
|
||||
"Value '9938489298493882949384989' out of range for source: 'ENVIRONMENT: " + env + "'",
|
||||
"message: " + error.GetMessage());
|
||||
}
|
||||
|
||||
VTKM_TEST_ASSERT(threw, "Should have thrown");
|
||||
}
|
||||
|
||||
// Parse an integer with some stuff on the end
|
||||
{
|
||||
internal::RuntimeDeviceOption testOption(TEST, env);
|
||||
my_setenv(env, "100bad");
|
||||
try
|
||||
{
|
||||
testOption.Initialize(nullptr);
|
||||
threw = false;
|
||||
}
|
||||
catch (const vtkm::cont::ErrorBadValue& error)
|
||||
{
|
||||
VTKM_TEST_ASSERT(error.GetMessage() ==
|
||||
"Value '100bad' from source: 'ENVIRONMENT: " + env +
|
||||
"' has dangling characters, throwing",
|
||||
"message: " + error.GetMessage());
|
||||
}
|
||||
|
||||
VTKM_TEST_ASSERT(threw, "Should have thrown");
|
||||
}
|
||||
|
||||
my_unsetenv(env);
|
||||
}
|
||||
|
||||
void TestRuntimeDeviceConfigurationOptions()
|
||||
{
|
||||
std::vector<opt::Descriptor> usage;
|
||||
usage.push_back({ opt::OptionIndex::DEVICE, 0, "", "tester", opt::VtkmArg::Required, "" });
|
||||
usage.push_back({ opt::OptionIndex::LOGLEVEL, 0, "", "filler", opt::VtkmArg::Required, "" });
|
||||
usage.push_back({ opt::OptionIndex::HELP, 0, "", "fancy", opt::VtkmArg::Required, "" });
|
||||
usage.push_back(
|
||||
{ opt::OptionIndex::DEPRECATED_DEVICE, 0, "", "just", opt::VtkmArg::Required, "" });
|
||||
usage.push_back(
|
||||
{ opt::OptionIndex::DEPRECATED_LOGLEVEL, 0, "", "gotta", opt::VtkmArg::Required, "" });
|
||||
|
||||
internal::RuntimeDeviceConfigurationOptions configOptions(usage);
|
||||
|
||||
usage.push_back({ opt::OptionIndex::UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
int argc;
|
||||
char** argv;
|
||||
MakeArgs(argc,
|
||||
argv,
|
||||
"--vtkm-num-threads",
|
||||
"100",
|
||||
"--vtkm-numa-regions",
|
||||
"2",
|
||||
"--vtkm-device-instance",
|
||||
"1");
|
||||
auto options = GetOptions(argc, argv, usage);
|
||||
|
||||
VTKM_TEST_ASSERT(!configOptions.IsInitialized(),
|
||||
"runtime config options should not be initialized");
|
||||
configOptions.Initialize(options.get());
|
||||
VTKM_TEST_ASSERT(configOptions.IsInitialized(), "runtime config options should be initialized");
|
||||
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmNumThreads.IsSet(), "num threads should be set");
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmNumaRegions.IsSet(), "numa regions should be set");
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmDeviceInstance.IsSet(), "device instance should be set");
|
||||
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmNumThreads.GetValue() == 100, "num threads should == 100");
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmNumaRegions.GetValue() == 2, "numa regions should == 2");
|
||||
VTKM_TEST_ASSERT(configOptions.VTKmDeviceInstance.GetValue() == 1, "device instance should == 1");
|
||||
}
|
||||
|
||||
void TestRuntimeConfigurationOptions()
|
||||
{
|
||||
TestRuntimeDeviceOptionHappy();
|
||||
TestRuntimeDeviceOptionError();
|
||||
TestRuntimeDeviceConfigurationOptions();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int UnitTestRuntimeConfigurationOptions(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestRuntimeConfigurationOptions, argc, argv);
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
#include <vtkm/cont/kokkos/internal/DeviceAdapterAlgorithmKokkos.h>
|
||||
#include <vtkm/cont/kokkos/internal/DeviceAdapterMemoryManagerKokkos.h>
|
||||
#include <vtkm/cont/kokkos/internal/DeviceAdapterRuntimeDetectorKokkos.h>
|
||||
#include <vtkm/cont/kokkos/internal/RuntimeDeviceConfigurationKokkos.h>
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
#include <vtkm/cont/kokkos/internal/VirtualObjectTransferKokkos.h>
|
||||
#endif //VTKM_NO_DEPRECATED_VIRTUAL
|
||||
|
@ -16,6 +16,7 @@ set(headers
|
||||
Initialize.h
|
||||
KokkosAlloc.h
|
||||
KokkosTypes.h
|
||||
RuntimeDeviceConfigurationKokkos.h
|
||||
)
|
||||
|
||||
if (NOT VTKm_NO_DEPRECATED_VIRTUAL)
|
||||
|
87
vtkm/cont/kokkos/internal/RuntimeDeviceConfigurationKokkos.h
Normal file
87
vtkm/cont/kokkos/internal/RuntimeDeviceConfigurationKokkos.h
Normal file
@ -0,0 +1,87 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_kokkos_internal_RuntimeDeviceConfigurationKokkos_h
|
||||
#define vtk_m_cont_kokkos_internal_RuntimeDeviceConfigurationKokkos_h
|
||||
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
#include <vtkm/cont/kokkos/internal/DeviceAdapterTagKokkos.h>
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagKokkos>
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
public:
|
||||
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagKokkos{};
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: set the kokkos threads
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetNumaRegions(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: set the kokkos numa regions
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetDeviceInstance(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: set the kokkos device instance
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: get the kokkos threads
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetNumaRegions(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: get the kokkos numa regions
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetDeviceInstance(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: get the kokkos device instance
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
protected:
|
||||
VTKM_CONT virtual void ParseExtraArguments(int&, char*[]) const override final
|
||||
{
|
||||
// TODO: ugh, kokkos. Manually parse the kokkos config args, store them for usage
|
||||
}
|
||||
|
||||
private:
|
||||
Kokkos::InitArguments ParsedCommandLineArgs;
|
||||
Kokkos::InitArguments VTKmInitializedArgs;
|
||||
};
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_kokkos_internal_RuntimeDeviceConfigurationKokkos_h
|
@ -17,6 +17,7 @@
|
||||
#ifdef VTKM_ENABLE_OPENMP
|
||||
#include <vtkm/cont/openmp/internal/DeviceAdapterAlgorithmOpenMP.h>
|
||||
#include <vtkm/cont/openmp/internal/DeviceAdapterMemoryManagerOpenMP.h>
|
||||
#include <vtkm/cont/openmp/internal/RuntimeDeviceConfigurationOpenMP.h>
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
#include <vtkm/cont/openmp/internal/VirtualObjectTransferOpenMP.h>
|
||||
#endif //VTKM_NO_DEPRECATED_VIRTUAL
|
||||
|
@ -18,6 +18,7 @@ set(headers
|
||||
ParallelRadixSortOpenMP.h
|
||||
ParallelScanOpenMP.h
|
||||
ParallelSortOpenMP.h
|
||||
RuntimeDeviceConfigurationOpenMP.h
|
||||
)
|
||||
|
||||
if (NOT VTKm_NO_DEPRECATED_VIRTUAL)
|
||||
|
61
vtkm/cont/openmp/internal/RuntimeDeviceConfigurationOpenMP.h
Normal file
61
vtkm/cont/openmp/internal/RuntimeDeviceConfigurationOpenMP.h
Normal file
@ -0,0 +1,61 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
|
||||
#define vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
|
||||
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
#include <vtkm/cont/openmp/internal/DeviceAdapterTagOpenMP.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagOpenMP>
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagOpenMP{};
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Set the threads in OpenMP
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetNumaRegions(
|
||||
const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Set the numa regions in OpenMP
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Get the number of OpenMP threads
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetNumaRegions(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Get the number of OpenMP NumaRegions
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
};
|
||||
} // namespace vtkm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_openmp_internal_RuntimeDeviceConfigurationOpenMP_h
|
@ -14,6 +14,7 @@
|
||||
// clang-format off
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterTagSerial.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterRuntimeDetectorSerial.h>
|
||||
#include <vtkm/cont/serial/internal/RuntimeDeviceConfigurationSerial.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterMemoryManagerSerial.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h>
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
|
@ -13,6 +13,7 @@ set(headers
|
||||
DeviceAdapterMemoryManagerSerial.h
|
||||
DeviceAdapterRuntimeDetectorSerial.h
|
||||
DeviceAdapterTagSerial.h
|
||||
RuntimeDeviceConfigurationSerial.h
|
||||
)
|
||||
|
||||
if (NOT VTKm_NO_DEPRECATED_VIRTUAL)
|
||||
|
36
vtkm/cont/serial/internal/RuntimeDeviceConfigurationSerial.h
Normal file
36
vtkm/cont/serial/internal/RuntimeDeviceConfigurationSerial.h
Normal file
@ -0,0 +1,36 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_serial_internal_RuntimeDeviceConfigurationSerial_h
|
||||
#define vtk_m_cont_serial_internal_RuntimeDeviceConfigurationSerial_h
|
||||
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterTagSerial.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagSerial>
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagSerial{};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //vtk_m_cont_serial_internal_RuntimeDeviceConfigurationSerial_h
|
@ -16,6 +16,7 @@
|
||||
#ifdef VTKM_ENABLE_TBB
|
||||
#include <vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h>
|
||||
#include <vtkm/cont/tbb/internal/DeviceAdapterMemoryManagerTBB.h>
|
||||
#include <vtkm/cont/tbb/internal/RuntimeDeviceConfigurationTBB.h>
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
#include <vtkm/cont/tbb/internal/VirtualObjectTransferTBB.h>
|
||||
#endif //VTKM_NO_DEPRECATED_VIRTUAL
|
||||
|
@ -15,6 +15,7 @@ set(headers
|
||||
DeviceAdapterTagTBB.h
|
||||
FunctorsTBB.h
|
||||
ParallelSortTBB.h
|
||||
RuntimeDeviceConfigurationTBB.h
|
||||
)
|
||||
|
||||
if (NOT VTKm_NO_DEPRECATED_VIRTUAL)
|
||||
|
48
vtkm/cont/tbb/internal/RuntimeDeviceConfigurationTBB.h
Normal file
48
vtkm/cont/tbb/internal/RuntimeDeviceConfigurationTBB.h
Normal file
@ -0,0 +1,48 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h
|
||||
#define vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h
|
||||
|
||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||
#include <vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagTBB>
|
||||
: public vtkm::cont::internal::RuntimeDeviceConfigurationBase
|
||||
{
|
||||
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const override final
|
||||
{
|
||||
return vtkm::cont::DeviceAdapterTagTBB{};
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode SetThreads(const vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: vtk-m set the number of global threads
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
|
||||
VTKM_CONT virtual RuntimeDeviceConfigReturnCode GetThreads(vtkm::Id&) const override final
|
||||
{
|
||||
// TODO: Get number of TBB threads here (essentially just threads supported by architecture)
|
||||
return RuntimeDeviceConfigReturnCode::SUCCESS;
|
||||
}
|
||||
};
|
||||
} // namespace vktm::cont::internal
|
||||
} // namespace vtkm::cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_tbb_internal_RuntimeDeviceConfigurationTBB_h
|
@ -73,59 +73,6 @@ enum TestOptionsIndex
|
||||
DEPRECATED_WRITEDIR // base dir for generated regression test images
|
||||
};
|
||||
|
||||
struct TestVtkmArg : public opt::Arg
|
||||
{
|
||||
static opt::ArgStatus Required(const opt::Option& option, bool msg)
|
||||
{
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error,
|
||||
"Missing argument after option '"
|
||||
<< std::string(option.name, static_cast<size_t>(option.namelen))
|
||||
<< "'.\n");
|
||||
}
|
||||
return opt::ARG_ILLEGAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Method used for guessing whether an option that do not support (perhaps that calling
|
||||
// program knows about it) has an option attached to it (which should also be ignored).
|
||||
static opt::ArgStatus Unknown(const opt::Option& option, bool msg)
|
||||
{
|
||||
// If we don't have an arg, obviously we don't have an arg.
|
||||
if (option.arg == nullptr)
|
||||
{
|
||||
return opt::ARG_NONE;
|
||||
}
|
||||
|
||||
// The opt::Arg::Optional method will return that the ARG is OK if and only if
|
||||
// the argument is attached to the option (e.g. --foo=bar). If that is the case,
|
||||
// then we definitely want to report that the argument is OK.
|
||||
if (opt::Arg::Optional(option, msg) == opt::ARG_OK)
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
|
||||
// Now things get tricky. Maybe the next argument is an option or maybe it is an
|
||||
// argument for this option. We will guess that if the next argument does not
|
||||
// look like an option, we will treat it as such.
|
||||
if (option.arg[0] == '-')
|
||||
{
|
||||
return opt::ARG_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return opt::ARG_OK;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Testing
|
||||
{
|
||||
public:
|
||||
@ -305,7 +252,7 @@ private:
|
||||
0,
|
||||
"",
|
||||
"vtkm-data-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --vtkm-data-dir "
|
||||
"<data-dir-path> \tPath to the "
|
||||
"base data directory in the VTK-m "
|
||||
@ -314,7 +261,7 @@ private:
|
||||
0,
|
||||
"",
|
||||
"vtkm-baseline-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --vtkm-baseline-dir "
|
||||
"<baseline-dir-path> "
|
||||
"\tPath to the base dir "
|
||||
@ -324,7 +271,7 @@ private:
|
||||
0,
|
||||
"",
|
||||
"vtkm-write-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --vtkm-write-dir "
|
||||
"<write-dir-path> "
|
||||
"\tPath to the write dir "
|
||||
@ -334,7 +281,7 @@ private:
|
||||
0,
|
||||
"D",
|
||||
"data-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --data-dir "
|
||||
"<data-dir-path> "
|
||||
"\tDEPRECATED: use --vtkm-data-dir instead" });
|
||||
@ -342,7 +289,7 @@ private:
|
||||
0,
|
||||
"B",
|
||||
"baseline-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --baseline-dir "
|
||||
"<baseline-dir-path> "
|
||||
"\tDEPRECATED: use --vtkm-baseline-dir instead" });
|
||||
@ -350,13 +297,13 @@ private:
|
||||
0,
|
||||
"",
|
||||
"write-dir",
|
||||
TestVtkmArg::Required,
|
||||
opt::VtkmArg::Required,
|
||||
" --write-dir "
|
||||
"<write-dir-path> "
|
||||
"\tDEPRECATED: use --vtkm-write-dir instead" });
|
||||
|
||||
// Required to collect unknown arguments when help is off.
|
||||
usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" });
|
||||
usage.push_back({ TEST_UNKNOWN, 0, "", "", opt::VtkmArg::UnknownOption, "" });
|
||||
usage.push_back({ 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
|
||||
|
@ -198,6 +198,24 @@ void InitializeDeprecatedOptionsWithArgs()
|
||||
CheckArgs(argc, argv, "--foo", "--", "--device", "Any", "--bar", "baz");
|
||||
}
|
||||
|
||||
void InitializeRuntimeDeviceConfigurationWithArgs()
|
||||
{
|
||||
int argc;
|
||||
char** argv;
|
||||
MakeArgs(argc,
|
||||
argv,
|
||||
"--device",
|
||||
"Any",
|
||||
"--vtkm-num-threads",
|
||||
"100",
|
||||
"--vtkm-numa-regions",
|
||||
"4",
|
||||
"--vtkm-device-instance",
|
||||
"2");
|
||||
vtkm::cont::Initialize(argc, argv);
|
||||
CheckArgs(argc, argv);
|
||||
}
|
||||
|
||||
void InitializeWithHelp()
|
||||
{
|
||||
std::cout << "Pass help flag to initialize" << std::endl;
|
||||
@ -224,6 +242,7 @@ void DoInitializeTests()
|
||||
InitializeMixedOptions();
|
||||
InitializeCustomOptionsWithArgs();
|
||||
InitializeDeprecatedOptionsWithArgs();
|
||||
InitializeRuntimeDeviceConfigurationWithArgs();
|
||||
|
||||
// This should be the last function called as it should exit with a zero status.
|
||||
InitializeWithHelp();
|
||||
|
Loading…
Reference in New Issue
Block a user