From 8894e7f04665fd6921066e76cc4cbcaea86323b0 Mon Sep 17 00:00:00 2001 From: Alastair Murray Date: Fri, 30 Oct 2020 15:01:48 +0000 Subject: [PATCH] Add memory_scope_all_devices testing (#999) * Add memory_scope_all_devices testing This duplicats memory_scope_all_svm_devices testing, but it seems pretty quick so I don't think it hurts. Fixes #990 * Address clang-format failures * Address a further clang-format failure --- test_conformance/c11_atomics/common.cpp | 19 ++++---- test_conformance/c11_atomics/common.h | 48 +++++++++++-------- test_conformance/c11_atomics/test_atomics.cpp | 6 ++- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/test_conformance/c11_atomics/common.cpp b/test_conformance/c11_atomics/common.cpp index c0cd265a..668d7b50 100644 --- a/test_conformance/c11_atomics/common.cpp +++ b/test_conformance/c11_atomics/common.cpp @@ -44,16 +44,12 @@ const char *get_memory_scope_type_name(TExplicitMemoryScopeType scopeType) { switch (scopeType) { - case MEMORY_SCOPE_EMPTY: - return ""; - case MEMORY_SCOPE_WORK_GROUP: - return "memory_scope_work_group"; - case MEMORY_SCOPE_DEVICE: - return "memory_scope_device"; - case MEMORY_SCOPE_ALL_SVM_DEVICES: - return "memory_scope_all_svm_devices"; - default: - return 0; + case MEMORY_SCOPE_EMPTY: return ""; + case MEMORY_SCOPE_WORK_GROUP: return "memory_scope_work_group"; + case MEMORY_SCOPE_DEVICE: return "memory_scope_device"; + case MEMORY_SCOPE_ALL_DEVICES: return "memory_scope_all_devices"; + case MEMORY_SCOPE_ALL_SVM_DEVICES: return "memory_scope_all_svm_devices"; + default: return 0; } } @@ -276,6 +272,9 @@ cl_int getSupportedMemoryOrdersAndScopes( } if (atomic_capabilities & CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES) { + // OpenCL 3.0 added memory_scope_all_devices as an alias for + // memory_scope_all_svm_devices, so test both. + memoryScopes.push_back(MEMORY_SCOPE_ALL_DEVICES); memoryScopes.push_back(MEMORY_SCOPE_ALL_SVM_DEVICES); } return CL_SUCCESS; diff --git a/test_conformance/c11_atomics/common.h b/test_conformance/c11_atomics/common.h index 3f0d2c5e..d1219f23 100644 --- a/test_conformance/c11_atomics/common.h +++ b/test_conformance/c11_atomics/common.h @@ -35,25 +35,26 @@ enum TExplicitAtomicType { - TYPE_ATOMIC_INT, - TYPE_ATOMIC_UINT, - TYPE_ATOMIC_LONG, - TYPE_ATOMIC_ULONG, - TYPE_ATOMIC_FLOAT, - TYPE_ATOMIC_DOUBLE, - TYPE_ATOMIC_INTPTR_T, - TYPE_ATOMIC_UINTPTR_T, - TYPE_ATOMIC_SIZE_T, - TYPE_ATOMIC_PTRDIFF_T, - TYPE_ATOMIC_FLAG + TYPE_ATOMIC_INT, + TYPE_ATOMIC_UINT, + TYPE_ATOMIC_LONG, + TYPE_ATOMIC_ULONG, + TYPE_ATOMIC_FLOAT, + TYPE_ATOMIC_DOUBLE, + TYPE_ATOMIC_INTPTR_T, + TYPE_ATOMIC_UINTPTR_T, + TYPE_ATOMIC_SIZE_T, + TYPE_ATOMIC_PTRDIFF_T, + TYPE_ATOMIC_FLAG }; enum TExplicitMemoryScopeType { - MEMORY_SCOPE_EMPTY, - MEMORY_SCOPE_WORK_GROUP, - MEMORY_SCOPE_DEVICE, - MEMORY_SCOPE_ALL_SVM_DEVICES + MEMORY_SCOPE_EMPTY, + MEMORY_SCOPE_WORK_GROUP, + MEMORY_SCOPE_DEVICE, + MEMORY_SCOPE_ALL_DEVICES, // Alias for MEMORY_SCOPE_ALL_SVM_DEVICES + MEMORY_SCOPE_ALL_SVM_DEVICES }; extern bool gHost; // temporary flag for testing native host threads (test verification) @@ -320,6 +321,7 @@ public: } break; } + case MEMORY_SCOPE_ALL_DEVICES: // fallthough case MEMORY_SCOPE_ALL_SVM_DEVICES: { if ((gAtomicMemCap & CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES) == 0) { @@ -538,11 +540,17 @@ public: } virtual cl_uint MaxHostThreads() { - // block host threads execution for memory scope different than memory_scope_all_svm_devices - if(MemoryScope() == MEMORY_SCOPE_ALL_SVM_DEVICES || gHost) - return CBasicTest::MaxHostThreads(); - else - return 0; + // block host threads execution for memory scope different than + // memory_scope_all_svm_devices + if (MemoryScope() == MEMORY_SCOPE_ALL_DEVICES + || MemoryScope() == MEMORY_SCOPE_ALL_SVM_DEVICES || gHost) + { + return CBasicTest::MaxHostThreads(); + } + else + { + return 0; + } } private: TExplicitMemoryOrderType _memoryOrder; diff --git a/test_conformance/c11_atomics/test_atomics.cpp b/test_conformance/c11_atomics/test_atomics.cpp index 6d8ffc9f..c3a190b7 100644 --- a/test_conformance/c11_atomics/test_atomics.cpp +++ b/test_conformance/c11_atomics/test_atomics.cpp @@ -1843,7 +1843,11 @@ public: } virtual bool SVMDataBufferAllSVMConsistent() { - return MemoryScope() == MEMORY_SCOPE_ALL_SVM_DEVICES; + // Although memory_scope_all_devices doesn't mention SVM it is just an + // alias for memory_scope_all_svm_devices. So both scopes interact with + // SVM allocations, on devices that support those, just the same. + return MemoryScope() == MEMORY_SCOPE_ALL_DEVICES + || MemoryScope() == MEMORY_SCOPE_ALL_SVM_DEVICES; } virtual int ExecuteForEachParameterSet(cl_device_id deviceID, cl_context context, cl_command_queue queue) {