Skip to content

Commit 538b36b

Browse files
author
Salinas, David
authored
Update amd/comgr/test-lit/spirv-to-reloc-debuginfo.hip (llvm#1532)
2 parents 5900c9f + f795529 commit 538b36b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// REQUIRES: comgr-has-spirv
2+
3+
// COM: Generate a debuginfo SPIR-V file from a HIP kernel
4+
// RUN: clang -x hip --offload-arch=amdgcnspirv -nogpulib -nogpuinc \
5+
// RUN: --no-gpu-bundle-output --offload-device-only -O3 %s -o %t.dbg.spv -g
6+
7+
// COM: Compile debuginfo SPIR-V source to a relocatable
8+
// RUN: AMD_COMGR_EMIT_VERBOSE_LOGS=1 AMD_COMGR_REDIRECT_LOGS=stdout \
9+
// RUN: spirv-to-reloc %t.dbg.spv %t.dbg.o | FileCheck \
10+
// RUN: -check-prefix=CHECK-DBG %s
11+
12+
// COM: Check that debuginfo SPIR-V flags are correctly extracted
13+
// CHECK-DBG: Driver Job Args: {{.*}} "-mllvm" "-amdgpu-spill-cfi-saved-regs"
14+
15+
#include <cstdlib>
16+
17+
#define __constant__ __attribute__((constant))
18+
#define __device__ __attribute__((device))
19+
#define __global__ __attribute__((global))
20+
#define __host__ __attribute__((host))
21+
#define __shared__ __attribute__((shared))
22+
#define __managed__ __attribute__((managed))
23+
#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
24+
25+
struct dim3 {
26+
unsigned x, y, z;
27+
__host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
28+
};
29+
30+
#ifdef __HIP__
31+
typedef struct hipStream *hipStream_t;
32+
typedef enum hipError {} hipError_t;
33+
int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
34+
hipStream_t stream = 0);
35+
extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
36+
size_t sharedSize = 0,
37+
hipStream_t stream = 0);
38+
extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
39+
dim3 blockDim, void **args,
40+
size_t sharedMem,
41+
hipStream_t stream);
42+
#endif
43+
44+
__attribute__((device))
45+
void clean_value(float* ptr) { *ptr = 0; }
46+
47+
__attribute__((global))
48+
void add_value(float* a, float* b, float* res) {
49+
*res = *a + *b;
50+
51+
clean_value(a);
52+
}

0 commit comments

Comments
 (0)