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][PTX] Enable to migrate "cp.async.commit_group", "cp.async.wait_group" and "cp.async.wait_all" #2588

Open
wants to merge 4 commits into
base: SYCLomatic
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions clang/lib/DPCT/RulesAsm/AsmMigration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,27 @@ class SYCLGen : public SYCLGenBase {
insertHeader(HeaderType::HT_DPCT_Atomic);
return SYCLGenSuccess();
}

bool handle_cp(const InlineAsmInstruction *Inst) override {
if (Inst->getNumInputOperands() == 0 && Inst->hasAttr(InstAttr::async) &&
(Inst->hasAttr(InstAttr::commit_group) ||
Inst->hasAttr(InstAttr::wait_group) ||
Inst->hasAttr(InstAttr::wait_all))) {
auto CommonStr = llvm::Twine("")
.concat("\"")
.concat(GAS->getAsmString()->getString())
.concat("\"")
.str();

report(Diagnostics::FUNC_CALL_REMOVED, true, CommonStr,
"SYCL currently has a functionality gap for asynchronous copy "
"operations. Synchronous copy operations are used on the SYCL "
"side and may cause performance issues. You may need to adjust "
"the code.");
return SYCLGenSuccess();
}
return SYCLGenError();
}
};

/// Clean the special character in identifier.
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/DPCT/RulesAsm/Parser/AsmTokenKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ MODIFIER(clamp, ".clamp")
MODIFIER(wrap, ".wrap")
MODIFIER(wide, ".wide")
MODIFIER(sync, ".sync")
MODIFIER(async, ".async")
MODIFIER(commit_group, ".commit_group")
MODIFIER(wait_group, ".wait_group")
MODIFIER(wait_all, ".wait_all")
MODIFIER(warp, ".warp")
MODIFIER(up, ".up")
MODIFIER(down, ".down")
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/DPCT/SrcAPI/APINames_ASM.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ENTRY("clz", "clz", true, NO_FLAG, P1, "Successful")
ENTRY("cnot", "cnot", true, NO_FLAG, P1, "Successful")
ENTRY("copysign", "copysign", true, NO_FLAG, P1, "Successful")
ENTRY("cos", "cos", true, NO_FLAG, P1, "Successful")
ENTRY("cp", "cp", false, NO_FLAG, P1, "Comment")
ENTRY("cp", "cp", true, NO_FLAG, P1, "Partial")
ENTRY("createpolicy", "createpolicy", false, NO_FLAG, P1, "Comment")
ENTRY("cvt", "cvt", true, NO_FLAG, P1, "Partial")
ENTRY("cvta", "cvta", false, NO_FLAG, P1, "Comment")
Expand Down
42 changes: 42 additions & 0 deletions clang/test/dpct/asm/cp.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2
// RUN: dpct --format-range=none -out-root %T/cp %s --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
// RUN: FileCheck %s --match-full-lines --input-file %T/cp/cp.dp.cpp
// RUN: %if build_lit %{icpx -c -fsycl %T/cp/cp.dp.cpp -o %T/cp/cp.dp.o %}

// clang-format off
#include <cuda_runtime.h>
#include <cstdint>

// CHECK:inline void cp_async_commit_group() {
// CHECK-NEXT: /*
// CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to "cp.async.commit_group;" was removed because SYCL currently has a functionality gap for asynchronous copy operations. Synchronous copy operations are used on the SYCL side and may cause performance issues. You may need to adjust the code.
// CHECK-NEXT: */
// CHECK-EMPTY:
// CHECK-NEXT:}
__device__ inline void cp_async_commit_group() {
asm volatile("cp.async.commit_group;" ::);
}


// CHECK:inline void cp_async_wait_group() {
// CHECK-NEXT: /*
// CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to "cp.async.wait_group 0;" was removed because SYCL currently has a functionality gap for asynchronous copy operations. Synchronous copy operations are used on the SYCL side and may cause performance issues. You may need to adjust the code.
// CHECK-NEXT: */
// CHECK-EMPTY:
// CHECK-NEXT:}
__device__ inline void cp_async_wait_group() {
asm volatile("cp.async.wait_group 0;");
}

// CHECK:inline void cp_async_wait_all() {
// CHECK-NEXT: /*
// CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to "cp.async.wait_all;" was removed because SYCL currently has a functionality gap for asynchronous copy operations. Synchronous copy operations are used on the SYCL side and may cause performance issues. You may need to adjust the code.
// CHECK-NEXT: */
// CHECK-EMPTY:
// CHECK-NEXT:}
__device__ inline void cp_async_wait_all() {
asm volatile("cp.async.wait_all;");
}

// clang-format on