summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-06-14 14:30:22 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2016-06-14 14:30:22 +0200
commit3e78a993559d936df4323abf6f4ee4f104508e3a (patch)
treeec97c76f473ee22217679f2fd11eb7e548cb2b0f
parent6e2017c67dcaafaac4b43b7a1161a44658fb5f4a (diff)
Moved device vendor and type checks to a common header
-rw-r--r--include/internal/clpp11.h6
-rw-r--r--include/internal/tuning.h6
-rw-r--r--src/routine.cc11
3 files changed, 12 insertions, 11 deletions
diff --git a/include/internal/clpp11.h b/include/internal/clpp11.h
index e70f9000..b834d8b4 100644
--- a/include/internal/clpp11.h
+++ b/include/internal/clpp11.h
@@ -207,6 +207,12 @@ class Device {
return true;
}
+ // Query for a specific type of device or brand
+ bool IsCPU() const { return Type() == "CPU"; }
+ bool IsGPU() const { return Type() == "GPU"; }
+ bool IsAMD() const { return Vendor() == "AMD" || Vendor() == "Advanced Micro Devices, Inc."; }
+ bool IsARM() const { return Vendor() == "ARM"; }
+
// Accessor to the private data-member
const cl_device_id& operator()() const { return device_; }
private:
diff --git a/include/internal/tuning.h b/include/internal/tuning.h
index 8fc79aff..a44f79d6 100644
--- a/include/internal/tuning.h
+++ b/include/internal/tuning.h
@@ -61,9 +61,9 @@ void Tuner(int argc, char* argv[]) {
printf("* Unsupported precision, skipping this tuning run\n\n");
return;
}
- isAMD = device.Vendor() == "AMD" || device.Vendor() == "Advanced Micro Devices, Inc.";
- isARM = device.Vendor() == "ARM";
- isGPU = device.Type() == "GPU";
+ isAMD = device.IsAMD();
+ isARM = device.IsARM();
+ isGPU = device.IsGPU();
}
// Creates input buffers with random data
diff --git a/src/routine.cc b/src/routine.cc
index 1acd814c..ca283b52 100644
--- a/src/routine.cc
+++ b/src/routine.cc
@@ -88,25 +88,20 @@ StatusCode Routine<T>::SetUp() {
// Adds the name of the routine as a define
defines += "#define ROUTINE_"+routine_name_+"\n";
- // Determines whether this is a specific device
- const auto isAMD = device_.Vendor() == "AMD" || device_.Vendor() == "Advanced Micro Devices, Inc.";
- const auto isARM = device_.Vendor() == "ARM";
- const auto isGPU = device_.Type() == "GPU";
-
// For specific devices, use the non-IEE754 compilant OpenCL mad() instruction. This can improve
// performance, but might result in a reduced accuracy.
- if (isAMD && isGPU) {
+ if (device_.IsAMD() && device_.IsGPU()) {
defines += "#define USE_CL_MAD 1\n";
}
// For specific devices, use staggered/shuffled workgroup indices.
- if (isAMD && isGPU) {
+ if (device_.IsAMD() && device_.IsGPU()) {
defines += "#define USE_STAGGERED_INDICES 1\n";
}
// For specific devices add a global synchronisation barrier to the GEMM kernel to optimize
// performance through better cache behaviour
- if (isARM && isGPU) {
+ if (device_.IsARM() && device_.IsGPU()) {
defines += "#define GLOBAL_MEM_FENCE 1\n";
}