Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCLomatic]Asm instr sub.f16x2 , ld.volatile.global/st.volatile.global #2484

Draft
wants to merge 7 commits into
base: SYCLomatic
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clang/lib/DPCT/RulesAsm/AsmMigration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,12 @@ class SYCLGen : public SYCLGenBase {
BI->getKind() != InlineAsmBuiltinType::s64 &&
BI->getKind() != InlineAsmBuiltinType::u64 &&
BI->getKind() != InlineAsmBuiltinType::s16x2 &&
BI->getKind() != InlineAsmBuiltinType::u16x2)
BI->getKind() != InlineAsmBuiltinType::u16x2 &&
BI->getKind() != InlineAsmBuiltinType::f16x2)
return false;
isVec = BI->getKind() == InlineAsmBuiltinType::s16x2 ||
BI->getKind() == InlineAsmBuiltinType::u16x2;
BI->getKind() == InlineAsmBuiltinType::u16x2 ||
BI->getKind() == InlineAsmBuiltinType::f16x2;
} else {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions clang/lib/DPCT/RulesAsm/Parser/AsmTokenKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ STATE_SPACE(reg, ".reg")
STATE_SPACE(sreg, ".sreg")
STATE_SPACE(const, ".const")
STATE_SPACE(global, ".global")
STATE_SPACE(volatile.global, ".volatile.global")
STATE_SPACE(local, ".local")
STATE_SPACE(param, ".param")
STATE_SPACE(shared, ".shared")
Expand Down
7 changes: 6 additions & 1 deletion clang/test/dpct/asm/ld.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cuda_runtime.h>

/*
.ss = { .const, .global, .local, .param, .shared };
.ss = { .const, .global, .local, .param, .shared, .volatile.global };
.type = { .b8, .b16, .b32, .b64, .b128,
.u8, .u16, .u32, .u64,
.s8, .s16, .s32, .s64,
Expand All @@ -27,6 +27,11 @@ __global__ void ld(int *arr) {
asm volatile ("ld.global.u32 %0, [%1 + 4];" : "=r"(c) : "l"(arr));
// CHECK: d = *((uint64_t *)((uintptr_t)arr + 8));
asm volatile ("ld.global.u64 %0, [%1 + 8];" : "=l"(d) : "l"(arr));
// CHECK: a = *arr;
asm volatile ("ld.volatile.global.s32 %0, [%1];" : "=r"(a) : "l"(arr));
// CHECK: b = *((uint32_t *)(uintptr_t)arr);
asm volatile ("ld.volatile.global.u32 %0, [%1];" : "=r"(b) : "l"(arr));
// CHECK: c = *((uint32_t *)((uintptr_t)arr + 4));
}

__device__ void shared_address_load32(uint32_t addr, uint32_t &val) {
Expand Down
14 changes: 14 additions & 0 deletions clang/test/dpct/asm/sub.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// clang-format off
#include <cuda_runtime.h>
#include <cstdint>
#include <cuda_fp16.h>

__global__ void sub() {
int x = 1, y = 2;
Expand All @@ -18,6 +19,7 @@ __global__ void sub() {
uint64_t u64;
short2 s16x2, sa{1, 2}, sb{1, 2};
ushort2 u16x2, ua{1, 2}, ub{1, 2};
half2 f16x2, fa{1.f, 2.f}, fb{1.f, 2.f};

// CHECK: i16 = x - y;
asm("sub.s16 %0, %1, %2;" : "=r"(i16) : "r"(x), "r"(y));
Expand All @@ -42,21 +44,33 @@ __global__ void sub() {

// CHECK: s16x2 = sa - sb;
asm("sub.s16x2 %0, %1, %2;" : "=r"(s16x2) : "r"(sa), "r"(sb));

// CHECK: f16x2 = fa - fb;
asm("sub.f16x2 %0, %1, %2;" : "=r"(f16x2) : "r"(fa), "r"(fb));

// CHECK: u16x2 = ua - ub;
asm("sub.u16x2 %0, %1, %2;" : "=r"(u16x2) : "r"(ua), "r"(ub));

// CHECK: s16x2 = sa - sycl::short2{1, 1};
asm("sub.s16x2 %0, %1, {1, 1};" : "=r"(s16x2) : "r"(sa));

// CHECK: f16x2 = fa - sycl::half2{1, 1};
asm("sub.f16x2 %0, %1, {1, 1};" : "=r"(f16x2) : "r"(fa));

// CHECK: u16x2 = ua - sycl::ushort2{1, 1};
asm("sub.u16x2 %0, %1, {1, 1};" : "=r"(u16x2) : "r"(ua));

// CHECK: s16x2 = sycl::short2{1, 1} - sa;
asm("sub.s16x2 %0, {1, 1}, %1;" : "=r"(s16x2) : "r"(sa));

// CHECK: f16x2 = sycl::half2{1, 1} - fa;
asm("sub.f16x2 %0, {1, 1}, %1;" : "=r"(f16x2) : "r"(fa));

// CHECK: u16x2 = sycl::ushort2{1, 1} - ua;
asm("sub.u16x2 %0, {1, 1}, %1;" : "=r"(u16x2) : "r"(ua));

// CHECK: f16x2 = sycl::half2{1, 1} - fa;
asm("sub.f16x2 %0, {1, 1}, %1;" : "=r"(f16x2) : "r"(fa));
}

// clang-format on