mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-24 07:59:01 +00:00
Fix SVM if 64-bit atomic extensions are supported (#382)
Need to enable 64-bit atomic extensions in kernel source. Use InterlockedCompareExchange64 for 64-bit type.
This commit is contained in:
@@ -44,7 +44,8 @@ bool AtomicCompareExchangeStrongExplicit(volatile T *a, T *expected, T desired,
|
|||||||
{
|
{
|
||||||
T tmp;
|
T tmp;
|
||||||
#if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32))
|
#if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32))
|
||||||
tmp = (T)InterlockedCompareExchange((volatile LONG *)a, (LONG)desired, *(LONG *)expected);
|
tmp = (sizeof(void*) == 8) ? (T)InterlockedCompareExchange64((volatile LONG64 *)a, (LONG64)desired, *(LONG64 *)expected) :
|
||||||
|
(T)InterlockedCompareExchange((volatile LONG*)a, (LONG)desired, *(LONG*)expected);
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
tmp = (T)__sync_val_compare_and_swap((volatile intptr_t*)a, (intptr_t)(*expected), (intptr_t)desired);
|
tmp = (T)__sync_val_compare_and_swap((volatile intptr_t*)a, (intptr_t)(*expected), (intptr_t)desired);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
//
|
//
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
const char *hash_table_kernel[] = {
|
static char hash_table_kernel[] =
|
||||||
|
"#if 0\n"
|
||||||
|
"#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable\n"
|
||||||
|
"#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable\n"
|
||||||
|
"#endif\n"
|
||||||
"typedef struct BinNode {\n"
|
"typedef struct BinNode {\n"
|
||||||
" int value;\n"
|
" int value;\n"
|
||||||
" atomic_uintptr_t pNext;\n"
|
" atomic_uintptr_t pNext;\n"
|
||||||
@@ -32,8 +36,7 @@ const char *hash_table_kernel[] = {
|
|||||||
" {\n"
|
" {\n"
|
||||||
" atomic_store_explicit(&(pNew->pNext), next, memory_order_seq_cst, memory_scope_all_svm_devices);\n" // always inserting at head of list
|
" atomic_store_explicit(&(pNew->pNext), next, memory_order_seq_cst, memory_scope_all_svm_devices);\n" // always inserting at head of list
|
||||||
" } while(!atomic_compare_exchange_strong_explicit(&(pNodes[b].pNext), &next, (uintptr_t)pNew, memory_order_seq_cst, memory_order_relaxed, memory_scope_all_svm_devices));\n"
|
" } while(!atomic_compare_exchange_strong_explicit(&(pNodes[b].pNext), &next, (uintptr_t)pNew, memory_order_seq_cst, memory_order_relaxed, memory_scope_all_svm_devices));\n"
|
||||||
"}\n"
|
"}\n";
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct BinNode{
|
typedef struct BinNode{
|
||||||
cl_uint value;
|
cl_uint value;
|
||||||
@@ -143,7 +146,12 @@ int test_svm_fine_grain_memory_consistency(cl_device_id deviceID, cl_context c,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = create_cl_objects(deviceID, &hash_table_kernel[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
|
// Make pragmas visible for 64-bit addresses
|
||||||
|
hash_table_kernel[4] = sizeof(void *) == 8 ? '1' : '0';
|
||||||
|
|
||||||
|
char *source[] = { hash_table_kernel };
|
||||||
|
|
||||||
|
err = create_cl_objects(deviceID, (const char**)source, &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
|
||||||
if(err == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
|
if(err == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
|
||||||
if(err < 0) return -1; // fail test.
|
if(err < 0) return -1; // fail test.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user