mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-08-22 21:12:26 +02:00
Merge pull request #93 from intelfx/test-read-environment
test/correctness: read platform and device from environment
This commit is contained in:
commit
478fb089d5
|
@ -161,6 +161,8 @@ template <typename T>
|
||||||
T ConvertArgument(const char* value) {
|
T ConvertArgument(const char* value) {
|
||||||
return static_cast<T>(std::stoi(value));
|
return static_cast<T>(std::stoi(value));
|
||||||
}
|
}
|
||||||
|
template size_t ConvertArgument(const char* value);
|
||||||
|
|
||||||
template <> half ConvertArgument(const char* value) {
|
template <> half ConvertArgument(const char* value) {
|
||||||
return FloatToHalf(static_cast<float>(std::stod(value)));
|
return FloatToHalf(static_cast<float>(std::stod(value)));
|
||||||
}
|
}
|
||||||
|
@ -179,6 +181,15 @@ template <> double2 ConvertArgument(const char* value) {
|
||||||
return double2{val, val};
|
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
|
// 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.
|
// default value in case the option is not found in the argument string.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -187,6 +187,10 @@ std::string ToString(T value);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ConvertArgument(const char* value);
|
T ConvertArgument(const char* value);
|
||||||
|
|
||||||
|
// Variant of "ConvertArgument" with default values
|
||||||
|
template <typename T>
|
||||||
|
T ConvertArgument(const char* value, T default_value);
|
||||||
|
|
||||||
// Basic argument parser, matching patterns in the form of "-option value" and "--option value"
|
// Basic argument parser, matching patterns in the form of "-option value" and "--option value"
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T GetArgument(const int argc, char **argv, std::string &help,
|
T GetArgument(const int argc, char **argv, std::string &help,
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "test/correctness/tester.hpp"
|
#include "test/correctness/tester.hpp"
|
||||||
|
|
||||||
|
@ -27,8 +28,8 @@ template <typename T, typename U>
|
||||||
Tester<T,U>::Tester(int argc, char *argv[], const bool silent,
|
Tester<T,U>::Tester(int argc, char *argv[], const bool silent,
|
||||||
const std::string &name, const std::vector<std::string> &options):
|
const std::string &name, const std::vector<std::string> &options):
|
||||||
help_("Options given/available:\n"),
|
help_("Options given/available:\n"),
|
||||||
platform_(Platform(GetArgument(argc, argv, help_, kArgPlatform, size_t{0}))),
|
platform_(Platform(GetArgument(argc, argv, help_, kArgPlatform, ConvertArgument(std::getenv("CLBLAST_PLATFORM"), size_t{0})))),
|
||||||
device_(Device(platform_, GetArgument(argc, argv, help_, kArgDevice, size_t{0}))),
|
device_(Device(platform_, GetArgument(argc, argv, help_, kArgDevice, ConvertArgument(std::getenv("CLBLAST_DEVICE"), size_t{0})))),
|
||||||
context_(Context(device_)),
|
context_(Context(device_)),
|
||||||
queue_(Queue(context_, device_)),
|
queue_(Queue(context_, device_)),
|
||||||
full_test_(CheckArgument(argc, argv, help_, kArgFullTest)),
|
full_test_(CheckArgument(argc, argv, help_, kArgFullTest)),
|
||||||
|
|
Loading…
Reference in a new issue