Open blueWatermelonFri opened 9 months ago
Hello @blueWatermelonFri,
The format specifier %d
expects an argument of type int
, not size_t
. The correct version of the code is
printf("%d %d\n", (int)sizeof(a_frag.x[0]), (int)sizeof(a_frag.x[1]));
I guess the reason for the output of 2 and 0 may be that size_t
takes 8 bytes, i.e., 0x00000002, so 0x0002 takes the place of the first %d
, and 0x0000 takes the place of the second %d
.
Additionally, you may have received a warning like:
warning #181-D: argument is incompatible with corresponding format string conversion (expected type "int" but argument has type "unsigned long long")
I encountered a strange bug while programming tensor core using the WMMA api in A800. I tried to print the size of the element in the fragment,Normally sizeof(fp16) is 2, the following code also outputs 2.
However, I changed the code to the following form, the print statement output 2 and 0, even i changed the order of
a_frag.x[0]
anda_frag.x[1]
, the output still is 2 and 0, Does anyone know why?My code runs in the following environment, os is ubuntu 20.04.
My compile command is: