Skip to content

Commit 3c0d6d2

Browse files
committed
printf bug
1 parent 4ab060f commit 3c0d6d2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

printf_bug/printf_bug.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <cstdio>
2+
#include "hip/hip_runtime.h"
3+
4+
class b {
5+
public:
6+
__host__ __device__
7+
b(uint32_t i) : v(i) {
8+
}
9+
uint32_t v;
10+
};
11+
12+
class bd: public b {
13+
public:
14+
__host__ __device__
15+
bd(uint32_t i) : b(i), bd_v(i + 1000) {
16+
printf("%s, %u, %u\n",
17+
__PRETTY_FUNCTION__, v, bd_v);
18+
}
19+
uint32_t bd_v;
20+
};
21+
22+
extern "C"
23+
__global__ void k(void* buffer) {
24+
new(buffer) bd(1000);
25+
}
26+
27+
int main() {
28+
29+
#if 0
30+
printf("CPU:\n");
31+
bd cpu(1000);
32+
#endif
33+
34+
void* buffer{nullptr};
35+
hipMalloc(&buffer, sizeof(bd));
36+
printf("GPU:\n");
37+
k<<<1,1>>>(buffer);
38+
hipFree(buffer);
39+
return 0;
40+
}
41+

0 commit comments

Comments
 (0)