39 lines · plain
1// RUN: echo -n "GPU binary would be here." > %t2// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \3// RUN: -target-sdk-version=11.0 -fcuda-include-gpubinary %t -o - \4// RUN: | FileCheck %s --check-prefixes CUDA5// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -x hip \6// RUN: -fcuda-include-gpubinary %t -o - \7// RUN: | FileCheck %s --check-prefixes HIP8 9#include "Inputs/cuda.h"10 11template <typename T>12struct S { T t; };13 14template <typename T>15 static __global__ void Kernel(S<T>) {}16 17// For some reason it takes three or more instantiations of Kernel to trigger a18// crash during CUDA compilation.19auto x = &Kernel<double>;20auto y = &Kernel<float>;21auto z = &Kernel<int>;22 23// This triggers HIP-specific code path.24void func (){25 Kernel<short><<<1,1>>>({1});26}27 28// CUDA-LABEL: @__cuda_register_globals(29// CUDA: call i32 @__cudaRegisterFunction(ptr %0, ptr @_ZL21__device_stub__KernelIdEv1SIT_E30// CUDA: call i32 @__cudaRegisterFunction(ptr %0, ptr @_ZL21__device_stub__KernelIfEv1SIT_E31// CUDA: call i32 @__cudaRegisterFunction(ptr %0, ptr @_ZL21__device_stub__KernelIiEv1SIT_E32// CUDA: ret void33 34// HIP-LABEL: @__hip_register_globals(35// HIP: call i32 @__hipRegisterFunction(ptr %0, ptr @_ZL6KernelIdEv1SIT_E36// HIP: call i32 @__hipRegisterFunction(ptr %0, ptr @_ZL6KernelIfEv1SIT_E37// HIP: call i32 @__hipRegisterFunction(ptr %0, ptr @_ZL6KernelIiEv1SIT_E38// HIP: ret void39