diff --git a/features/config/TEMPLATE_module.xml b/features/config/TEMPLATE_module.xml index 7418c2a31..7cfad47a9 100644 --- a/features/config/TEMPLATE_module.xml +++ b/features/config/TEMPLATE_module.xml @@ -3,8 +3,10 @@ test - - - + + + + + diff --git a/features/feature_case/module/do_test.py b/features/feature_case/module/do_test.py new file mode 100644 index 000000000..efe66ae5a --- /dev/null +++ b/features/feature_case/module/do_test.py @@ -0,0 +1,42 @@ +# ====------ do_test.py---------- *- Python -* ----===## +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# +# ===----------------------------------------------------------------------===# +import subprocess +import platform +import os +import sys +from test_config import CT_TOOL + +from test_utils import * + +def setup_test(): + change_dir(test_config.current_test) + return True + +def migrate_test(): + # clean previous migration output + if (os.path.exists("dpct_output")): + shutil.rmtree("dpct_output") + call_subprocess(test_config.CT_TOOL + " --cuda-include-path=" + test_config.include_path + " module-helper.cpp module-main.cu module-kernel.cu --extra-arg=--ptx") + return os.path.exists(os.path.join("dpct_output", "module-kernel.dp.cpp")) +def build_test(): + # make shared library + if (platform.system() == 'Windows'): + ret = call_subprocess("icpx -fsycl dpct_output/module-kernel.dp.cpp -shared -o module-kernel.dll") + else: + ret = call_subprocess(test_config.DPCXX_COM + " dpct_output/module-kernel.dp.cpp -fPIC -shared -o module-kernel.so") + if not ret: + print("Could not make module-kernel.* shared library.") + return False + + srcs = [] + srcs.append(os.path.join("dpct_output", "module-helper.cpp")) + srcs.append(os.path.join("dpct_output", "module-main.dp.cpp")) + return compile_and_link(srcs) +def run_test(): + return call_subprocess(os.path.join(os.path.curdir, test_config.current_test + '.run ')) diff --git a/features/feature_case/module/module-kernel.cu b/features/feature_case/module/module-kernel.cu index c6a22aadd..9657defb7 100644 --- a/features/feature_case/module/module-kernel.cu +++ b/features/feature_case/module/module-kernel.cu @@ -8,9 +8,9 @@ // ===----------------------------------------------------------------------===// static texture tex; -__global__ void foo(float* k, float* y); +extern "C" __global__ void foo(float* k, float* y); -__global__ void foo(float* k, float* y){ +extern "C" __global__ void foo(float* k, float* y){ extern __shared__ int s[]; int a = threadIdx.x; } diff --git a/features/feature_case/module/module-main.cu b/features/feature_case/module/module-main.cu index 1d53a3884..8ca49949a 100644 --- a/features/feature_case/module/module-main.cu +++ b/features/feature_case/module/module-main.cu @@ -10,10 +10,14 @@ int main(){ CUmodule M; CUfunction F; - std::string Path, FunctionName, Data; +#ifdef _WIN32 + std::string Path{"./module-kernel.dll"}; +#else + std::string Path{"./module-kernel.so"}; +#endif + std::string FunctionName{"foo"}, Data; FunctionName = "foo"; cuModuleLoad(&M, Path.c_str()); - cuModuleLoadData(&M, Data.c_str()); cuModuleGetFunction(&F, M, FunctionName.c_str()); float *param[2] = {0}; cudaMalloc(¶m[0], sizeof(float)); diff --git a/features/features.xml b/features/features.xml index 07bfee6c7..aa0164473 100644 --- a/features/features.xml +++ b/features/features.xml @@ -102,7 +102,7 @@ - +