Skip to content

Commit 41da13d

Browse files
committed
additionally print values as hex and float
1 parent 321dd84 commit 41da13d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

samples/05_kernelfromfile/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ int main(
121121
0,
122122
gwx * sizeof( cl_uint ) );
123123

124-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
124+
printf("First few values:\n"
125+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
126+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
127+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
128+
ptr[0], ptr[0], *((float*)&ptr[0]),
129+
ptr[1], ptr[1], *((float*)&ptr[1]),
130+
ptr[2], ptr[2], *((float*)&ptr[2]));
125131

126132
commandQueue.enqueueUnmapMemObject(
127133
deviceMemDst,

samples/05_spirvkernelfromfile/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ int main(
204204
0,
205205
gwx * sizeof( cl_uint ) );
206206

207-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
207+
printf("First few values:\n"
208+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
209+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
210+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
211+
ptr[0], ptr[0], *((float*)&ptr[0]),
212+
ptr[1], ptr[1], *((float*)&ptr[1]),
213+
ptr[2], ptr[2], *((float*)&ptr[2]));
208214

209215
commandQueue.enqueueUnmapMemObject(
210216
deviceMemDst,

samples/06_ndrangekernelfromfile/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ int main(
165165
0,
166166
gwx * gwy * sizeof( cl_uint ) );
167167

168-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
168+
printf("First few values:\n"
169+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
170+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
171+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
172+
ptr[0], ptr[0], *((float*)&ptr[0]),
173+
ptr[1], ptr[1], *((float*)&ptr[1]),
174+
ptr[2], ptr[2], *((float*)&ptr[2]));
169175

170176
commandQueue.enqueueUnmapMemObject(
171177
deviceMemDst,

0 commit comments

Comments
 (0)