From ea43936e94fdf2eabb913c1ebc1ac6143bde5bba Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Sat, 2 Jul 2016 02:38:48 +0300 Subject: 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`. --- src/utilities.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/utilities.cpp') 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 T ConvertArgument(const char* value) { return static_cast(std::stoi(value)); } +template size_t ConvertArgument(const char* value); + template <> half ConvertArgument(const char* value) { return FloatToHalf(static_cast(std::stod(value))); } @@ -179,6 +181,15 @@ template <> double2 ConvertArgument(const char* value) { return double2{val, val}; } +// Variant of "ConvertArgument" with default values +template +T ConvertArgument(const char* value, T default_value) { + + if (value) { return ConvertArgument(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 -- cgit v1.2.3