MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / test_atomic_function

Function test_atomic_function

test_conformance/atomics/test_atomics.cpp:126–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126int test_atomic_function(cl_device_id deviceID, cl_context context,
127 cl_command_queue queue, int num_elements,
128 const char *programCore, TestFns testFns,
129 bool extended, bool isLocal, ExplicitType dataType,
130 bool matchGroupSize)
131{
132 clProgramWrapper program;
133 clKernelWrapper kernel;
134 int error;
135 size_t threads[1];
136 clMemWrapper streams[2];
137 std::vector<char> refValues;
138 std::vector<char> startRefValues;
139 size_t threadSize, groupSize;
140 const char *programLines[4];
141 char pragma[512];
142 char programHeader[512];
143 size_t typeSize = get_explicit_type_size(dataType);
144
145
146 // Verify we can run first
147 bool isUnsigned = (dataType == kULong) || (dataType == kUInt);
148 if (!check_atomic_support(deviceID, extended, isLocal, dataType))
149 {
150 // Only print for the signed (unsigned comes right after, and if signed
151 // isn't supported, unsigned isn't either)
152 if (dataType == kFloat)
153 log_info("\t%s float not supported\n",
154 isLocal ? "Local" : "Global");
155 else if (!isUnsigned)
156 log_info("\t%s %sint%d not supported\n",
157 isLocal ? "Local" : "Global", isUnsigned ? "u" : "",
158 (int)typeSize * 8);
159 // Since we don't support the operation, they implicitly pass
160 return 0;
161 }
162 else
163 {
164 if (dataType == kFloat)
165 log_info("\t%s float%s...", isLocal ? "local" : "global",
166 isLocal ? " " : "");
167 else
168 log_info("\t%s %sint%d%s%s...", isLocal ? "local" : "global",
169 isUnsigned ? "u" : "", (int)typeSize * 8,
170 isUnsigned ? "" : " ", isLocal ? " " : "");
171 }
172
173 //// Set up the kernel code
174
175 // Create the pragma line for this kernel
176 bool isLong = (dataType == kLong || dataType == kULong);
177 sprintf(pragma,
178 "#pragma OPENCL EXTENSION cl_khr%s_int%s_%s_atomics : enable\n",
179 isLong ? "" : (isLocal ? "_local" : "_global"),
180 isLong ? "64" : "32", extended ? "extended" : "base");
181
182 // Now create the program header
183 const char *typeName = get_explicit_type_name(dataType);

Callers 2

test_atomic_function_setFunction · 0.85
REGISTER_TESTFunction · 0.85

Calls 5

get_explicit_type_sizeFunction · 0.85
check_atomic_supportFunction · 0.85
get_explicit_type_nameFunction · 0.85

Tested by

no test coverage detected