diff options
author | Ivan Shapovalov <intelfx@intelfx.name> | 2016-07-02 02:38:48 +0300 |
---|---|---|
committer | Ivan Shapovalov <intelfx@intelfx.name> | 2016-08-27 05:37:26 +0300 |
commit | ea43936e94fdf2eabb913c1ebc1ac6143bde5bba (patch) | |
tree | 472e138c8e5d1ca1dc3612030fe775414662845d /src/utilities.cpp | |
parent | 8d6a6a5bbf7811d7dff799ed8c1c12d63bca19db (diff) |
test/correctness: read platform and device from environment
Support passing environment variables CLBLAST_PLATFORM and CLBLAST_DEVICE
instead of -platform and -device arguments to test executables.
This is for `ctest`.
Diffstat (limited to 'src/utilities.cpp')
-rw-r--r-- | src/utilities.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utilities.cpp b/src/utilities.cpp index 11a6c439..77bc72d7 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -161,6 +161,8 @@ template <typename T> T ConvertArgument(const char* value) { return static_cast<T>(std::stoi(value)); } +template size_t ConvertArgument(const char* value); + template <> half ConvertArgument(const char* value) { return FloatToHalf(static_cast<float>(std::stod(value))); } @@ -179,6 +181,15 @@ template <> double2 ConvertArgument(const char* value) { return double2{val, val}; } +// Variant of "ConvertArgument" with default values +template <typename T> +T ConvertArgument(const char* value, T default_value) { + + if (value) { return ConvertArgument<T>(value); } + return default_value; +} +template size_t ConvertArgument(const char* value, size_t default_value); + // This function matches patterns in the form of "-option value" or "--option value". It returns a // default value in case the option is not found in the argument string. template <typename T> |