Skip to content

Commit 24e57b3

Browse files
committed
minor changes
1 parent d6ef28a commit 24e57b3

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

tests/opencl/psort/main.cc

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,17 @@ int main (int argc, char **argv) {
148148
h_c = (int*)malloc(nbytes);
149149

150150
// Generate input values
151-
151+
for (int i = 0; i < size; ++i) {
152+
if (float_enable) {
153+
float value = sinf(i)*sinf(i);
154+
((float*)h_a)[i] = value;
155+
printf("*** [%d]: %f\n", i, value);
156+
} else {
157+
int value = size*sinf(i);
158+
h_a[i] = value;
159+
printf("*** [%d]: %d\n", i, value);
160+
}
161+
}
152162

153163
// Creating command queue
154164
commandQueue = CL_CHECK2(clCreateCommandQueue(context, device_id, 0, &_err));
@@ -160,10 +170,6 @@ int main (int argc, char **argv) {
160170
// update for vortex divergence paper
161171
size_t global_work_size[1] = {size};
162172
size_t local_work_size[1] = {256}; // {1};
163-
printf("global work size: %d\n", (int)global_work_size[0]);
164-
printf("local work size: %d\n", (int)local_work_size[0]);
165-
166-
167173
auto time_start = std::chrono::high_resolution_clock::now();
168174
CL_CHECK(clEnqueueNDRangeKernel(commandQueue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL));
169175
CL_CHECK(clFinish(commandQueue));
@@ -175,7 +181,15 @@ int main (int argc, char **argv) {
175181
CL_CHECK(clEnqueueReadBuffer(commandQueue, c_memobj, CL_TRUE, 0, nbytes, h_c, 0, NULL, NULL));
176182

177183
printf("Verify result\n");
178-
184+
for (int i = 0; i < size; ++i) {
185+
if (float_enable) {
186+
float value = ((float*)h_c)[i];
187+
printf("*** [%d]: %f\n", i, value);
188+
} else {
189+
int value = h_c[i];
190+
printf("*** [%d]: %d\n", i, value);
191+
}
192+
}
179193
int errors = 0;
180194
for (int i = 0; i < size; ++i) {
181195
int pos = 0;
@@ -186,15 +200,12 @@ int main (int argc, char **argv) {
186200
pos += (cur < ref) || (cur == ref && j < i);
187201
}
188202
float value = ((float*)h_c)[pos];
189-
190-
if (!((std::isnan(value) && std::isnan(ref)) || (value == ref)) && value != ref) {
203+
if (value != ref) {
191204
if (errors < 100) {
192-
printf("*** error 1: [%d] expected=%f, actual=%f\n", pos, ref, value);
205+
printf("*** error: [%d] expected=%f, actual=%f\n", pos, ref, value);
193206
}
194207
++errors;
195208
}
196-
197-
198209
} else {
199210
int ref = h_a[i];
200211
for (int j = 0; j < size; ++j) {
@@ -204,7 +215,7 @@ int main (int argc, char **argv) {
204215
int value = h_c[pos];
205216
if (value != ref) {
206217
if (errors < 100) {
207-
printf("*** error 2: [%d] expected=%d, actual=%d\n", pos, ref, value);
218+
printf("*** error: [%d] expected=%d, actual=%d\n", pos, ref, value);
208219
}
209220
++errors;
210221
}
@@ -220,4 +231,4 @@ int main (int argc, char **argv) {
220231
cleanup();
221232

222233
return errors;
223-
}
234+
}

0 commit comments

Comments
 (0)