Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: intwanghao <[email protected]>
  • Loading branch information
intwanghao committed May 7, 2024
1 parent 42b0f63 commit 8b1a2c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions clang/test/dpct/macro_rule.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: dpct --rule-file=%S/../../tools/dpct/DpctOptRules/macro.yaml --format-range=none -out-root %T/macro_rule %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
// RUN: FileCheck --input-file %T/macro_rule/macro_rule.dp.cpp --match-full-lines %s
// RUN: %if build_lit %{icpx -c -fsycl %T/macro_rule/macro_rule.dp.cpp -o %T/macro_rule/macro_rule.dp.o %}
#include <cuda_runtime.h>

#define CUDA_CHECK(err) err

int main() {
int *ptr;
// CHECK: DPCT_CHECK_ERROR(ptr = (int *)sycl::malloc_device(10, dpct::get_in_order_queue()));
CUDA_CHECK(cudaMalloc(&ptr, 10));
return 0;
}
1 change: 1 addition & 0 deletions clang/tools/dpct/DpctOptRules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(dpct_opt_rule_files
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/DpctOptRules/forceinline.yaml
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/DpctOptRules/intel_specific_math.yaml
${CMAKE_SOURCE_DIR}/../clang/tools/dpct/DpctOptRules/macro.yaml
)

set(dpct_cmake_rule_files
Expand Down
18 changes: 18 additions & 0 deletions clang/tools/dpct/DpctOptRules/macro.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) Intel Corporation
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# See https://llvm.org/LICENSE.txt for license information.

# This file is an example of user defined migration rules.
# Applying this rule will make DPCT migrate macro CUDA_CHECK to DPCT_CHECK_ERROR.
# This file will be installed to folder:
# {dpct_install_folder}/extensions/opt_rules.
# The rule specified in this file can be imported with commandline option:
# --rule-file={dpct_install_folder}/extensions/opt_rules/macro.yaml
---
- Rule: rule_error_check_macro # specify an unique name(ID) of the rule
Kind: Macro # specify the kind of the rule
Priority: Takeover # select the priority if the rule conflicts with another one. value = Fallback/Default/Takeover
In: CUDA_CHECK # the target macro need to be migrate
Out: DPCT_CHECK_ERROR # the new macro name
Includes: [] # if the new macro depends on header files, specify it here as a list
# e.g.["header_1.h", "<vector>"]

0 comments on commit 8b1a2c8

Please sign in to comment.