Skip to content

Commit b0eae3d

Browse files
authored
additionally print values as hex and float (#156)
1 parent 196d94c commit b0eae3d

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
@@ -127,7 +127,13 @@ int main(
127127
0,
128128
gwx * sizeof( cl_uint ) );
129129

130-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
130+
printf("First few values:\n"
131+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
132+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
133+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
134+
ptr[0], ptr[0], *((float*)&ptr[0]),
135+
ptr[1], ptr[1], *((float*)&ptr[1]),
136+
ptr[2], ptr[2], *((float*)&ptr[2]));
131137

132138
commandQueue.enqueueUnmapMemObject(
133139
deviceMemDst,

samples/05_spirvkernelfromfile/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ int main(
208208
0,
209209
gwx * sizeof( cl_uint ) );
210210

211-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
211+
printf("First few values:\n"
212+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
213+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
214+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
215+
ptr[0], ptr[0], *((float*)&ptr[0]),
216+
ptr[1], ptr[1], *((float*)&ptr[1]),
217+
ptr[2], ptr[2], *((float*)&ptr[2]));
212218

213219
commandQueue.enqueueUnmapMemObject(
214220
deviceMemDst,

samples/06_ndrangekernelfromfile/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ int main(
171171
0,
172172
gwx * gwy * sizeof( cl_uint ) );
173173

174-
printf("First few values: [0] = %u, [1] = %u, [2] = %u\n", ptr[0], ptr[1], ptr[2]);
174+
printf("First few values:\n"
175+
" [0] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
176+
" [1] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n"
177+
" [2] = 0x%08X (as hex) = %u (as int) = %.2f (as float)\n",
178+
ptr[0], ptr[0], *((float*)&ptr[0]),
179+
ptr[1], ptr[1], *((float*)&ptr[1]),
180+
ptr[2], ptr[2], *((float*)&ptr[2]));
175181

176182
commandQueue.enqueueUnmapMemObject(
177183
deviceMemDst,

0 commit comments

Comments
 (0)