Skip to content
Snippets Groups Projects

Replace PyCuda with CuPy

Merged Markus Holzer requested to merge holzer/pystencils:cupy into master
Viewing commit 14fe17a7
Prev
Show latest version
5 files
+ 12
1253
Preferences
Compare changes
Files
5
+ 6
9
@@ -39,14 +39,10 @@ def make_python_function(kernel_function_node, argument_dict=None, custom_backen
if argument_dict is None:
argument_dict = {}
# if cp.cuda.runtime.is_hip:
header_list = ['<cstdint>'] + list(get_headers(kernel_function_node))
backend = "nvrtc"
options = ["-w", "-std=c++11"]
# else:
# header_list = ['<cstdint>'] + list(get_headers(kernel_function_node))
# backend = "nvcc"
# options = ["-w", "-std=c++11", "-Wno-deprecated-gpu-targets", "-m64"]
if cp.cuda.runtime.is_hip:
header_list = ['"gpu_defines.h"'] + list(get_headers(kernel_function_node))
else:
header_list = ['"gpu_defines.h"', '<cstdint>'] + list(get_headers(kernel_function_node))
includes = "\n".join([f"#include {include_file}" for include_file in header_list])
code = includes + "\n"
@@ -55,11 +51,12 @@ def make_python_function(kernel_function_node, argument_dict=None, custom_backen
code += str(generate_cuda(kernel_function_node, custom_backend=custom_backend))
code = 'extern "C" {\n%s\n}\n' % code
options = ["-w", "-std=c++11"]
if USE_FAST_MATH:
options.append("-use_fast_math")
options.append("-I" + get_pystencils_include_path())
mod = cp.RawModule(code=code, options=tuple(options), backend=backend, jitify=True)
mod = cp.RawModule(code=code, options=tuple(options), backend="nvrtc", jitify=True)
func = mod.get_function(kernel_function_node.function_name)
parameters = kernel_function_node.get_parameters()