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] Add rule for error check macro migration #1949

Merged
merged 3 commits into from
May 10, 2024
Merged
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
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_checks.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_checks.yaml
)

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

# This rule target to migrate macro CUDA_CHECK to DPCT_CHECK_ERROR.
# The rule specified in this file can be imported with commandline option:
# --rule-file={dpct_install_folder}/extensions/opt_rules/macro_checks.yaml
---
- Rule: rule_error_check_macro # Specify a 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 needs to be migrated
Out: DPCT_CHECK_ERROR # the macro used in migration
Includes: [] # if the macro used in Out field depends on header files, specify it here
# e.g.["header_1.h", "<vector>"]
Loading