|
| 1 | +// RUN: %clang_cc1 -x cuda -triple nvptx64-nvidia-cuda- -fcuda-is-device \ |
| 2 | +// RUN: -O3 -S %s -o - | FileCheck -check-prefix=PTX %s |
| 3 | +// RUN: %clang_cc1 -x cuda -triple nvptx64-nvidia-cuda- -fcuda-is-device \ |
| 4 | +// RUN: -Os -S %s -o - | FileCheck -check-prefix=PTX %s |
| 5 | +#include "Inputs/cuda.h" |
| 6 | + |
| 7 | +// PTX-LABEL: .func _Z12copy_genericPvPKv( |
| 8 | +void __device__ copy_generic(void *dest, const void *src) { |
| 9 | + __builtin_memcpy(dest, src, 32); |
| 10 | +// PTX: ld.u8 |
| 11 | +// PTX: st.u8 |
| 12 | +} |
| 13 | + |
| 14 | +// PTX-LABEL: .entry _Z11copy_globalPvS_( |
| 15 | +void __global__ copy_global(void *dest, void * src) { |
| 16 | + __builtin_memcpy(dest, src, 32); |
| 17 | +// PTX: ld.global.u8 |
| 18 | +// PTX: st.global.u8 |
| 19 | +} |
| 20 | + |
| 21 | +struct S { |
| 22 | + int data[8]; |
| 23 | +}; |
| 24 | + |
| 25 | +// PTX-LABEL: .entry _Z20copy_param_to_globalP1SS_( |
| 26 | +void __global__ copy_param_to_global(S *global, S param) { |
| 27 | + __builtin_memcpy(global, ¶m, sizeof(S)); |
| 28 | +// PTX: ld.param.u32 |
| 29 | +// PTX: st.global.u32 |
| 30 | +} |
| 31 | + |
| 32 | +// PTX-LABEL: .entry _Z19copy_param_to_localPU3AS51SS_( |
| 33 | +void __global__ copy_param_to_local(__attribute__((address_space(5))) S *local, |
| 34 | + S param) { |
| 35 | + __builtin_memcpy(local, ¶m, sizeof(S)); |
| 36 | +// PTX: ld.param.u32 |
| 37 | +// PTX: st.local.u32 |
| 38 | +} |
| 39 | + |
| 40 | +// PTX-LABEL: .func _Z21copy_local_to_genericP1SPU3AS5S_( |
| 41 | +void __device__ copy_local_to_generic(S *generic, |
| 42 | + __attribute__((address_space(5))) S *src) { |
| 43 | + __builtin_memcpy(generic, src, sizeof(S)); |
| 44 | +// PTX: ld.local.u32 |
| 45 | +// PTX: st.u32 |
| 46 | +} |
| 47 | + |
| 48 | +__shared__ S shared; |
| 49 | + |
| 50 | +// PTX-LABEL: .entry _Z20copy_param_to_shared1S( |
| 51 | +void __global__ copy_param_to_shared( S param) { |
| 52 | + __builtin_memcpy(&shared, ¶m, sizeof(S)); |
| 53 | +// PTX: ld.param.u32 |
| 54 | +// PTX: st.shared.u32 |
| 55 | +} |
| 56 | + |
| 57 | +void __device__ copy_shared_to_generic(S *generic) { |
| 58 | + __builtin_memcpy(generic, &shared, sizeof(S)); |
| 59 | +// PTX: ld.shared.u32 |
| 60 | +// PTX: st.u32 |
| 61 | +} |
0 commit comments