Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2460b3a
remove unused imports
May 19, 2025
143537c
add windows_compilations subpackage to keopscore
Louis-Pujol May 19, 2025
c17d6e3
Use vectors in utils_pe.h
Louis-Pujol May 19, 2025
4abebfd
lint
Louis-Pujol May 19, 2025
5bd1c0e
move windows compilmations to an independant package
Louis-Pujol Jun 28, 2025
fdba11f
move back windows compability to keopscore
Louis-Pujol Jul 11, 2025
b3def29
add windows specific cpp files
Louis-Pujol Jul 11, 2025
3631b9e
lint
Louis-Pujol Jul 11, 2025
c202719
typo in pybind11 code
Louis-Pujol Jul 11, 2025
f13f62b
add `windows_compilation` package to `setup.py`
Louis-Pujol Jul 11, 2025
0ae6e89
update setup.pys (ugly fix for version on windows)
Louis-Pujol Jul 11, 2025
2888424
remove breakpoints
Louis-Pujol Jul 11, 2025
830deb7
cuda detection: set use cuda to false if CUDA_PATH is not accessible
Louis-Pujol Jul 11, 2025
5a51e69
lint
Louis-Pujol Jul 11, 2025
52f9b7e
fix cuda detection
Louis-Pujol Jul 11, 2025
e1f304c
lint
Louis-Pujol Jul 11, 2025
0222d16
fix argument types in call_keops for windows
Louis-Pujol Jul 11, 2025
593b059
change type annotations for paths
Louis-Pujol Jul 11, 2025
3144bad
fix annotations issues in compile.py
Louis-Pujol Jul 11, 2025
f3813c6
fix typing for paths
Louis-Pujol Jul 11, 2025
eb0e52a
remove dummy print
Louis-Pujol Jul 11, 2025
192c0df
use cuda-pathfinder to find cuda dlls on windows
Louis-Pujol Sep 19, 2025
58cb294
lint
Louis-Pujol Sep 19, 2025
7ba9619
remove cuda pathfinder, check x86 folder for cuda dlls
Sep 19, 2025
e890b20
typo x86 -> x64
Sep 19, 2025
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
6 changes: 5 additions & 1 deletion keopscore/keopscore/binders/LinkCompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def read_info(self):
def write_code(self):
# write the generated code in the source file ; this is used as a subfunction of compile_code
f = open(self.gencode_file, "w")
f.write(self.code)
if os.name == "nt":
f.write(self.code.replace("signed long int", "int"))
else:
f.write(self.code)

f.close()

def generate_code(self):
Expand Down
62 changes: 42 additions & 20 deletions keopscore/keopscore/binders/nvrtc/Gpu_link_compile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from ctypes import create_string_buffer, CDLL, c_int
from os import RTLD_LAZY
import sysconfig
from os.path import join

Expand Down Expand Up @@ -34,10 +33,13 @@


def jit_compile_dll():
return os.path.join(
build_folder,
"nvrtc_jit" + sysconfig.get_config_var("SHLIB_SUFFIX"),
)
if os.name == "nt":
return os.path.join(build_folder, "nvrtc_jit.dll")
else:
return os.path.join(
build_folder,
"nvrtc_jit" + sysconfig.get_config_var("SHLIB_SUFFIX"),
)


class Gpu_link_compile(LinkCompile):
Expand All @@ -61,7 +63,10 @@ def __init__(self):
self.low_level_code_prefix + self.gencode_filename,
).encode("utf-8")

self.my_c_dll = CDLL(jit_compile_dll(), mode=RTLD_LAZY)
if os.name != "nt":
self.my_c_dll = CDLL(jit_compile_dll(), mode=os.RTLD_LAZY)
else:
self.my_c_dll = CDLL(jit_compile_dll())
# actual dll to be called is the jit binary, TODO: check if this is relevent
self.true_dllname = jit_binary
# file to check for existence to detect compilation is needed
Expand All @@ -75,16 +80,27 @@ def generate_code(self):
self.write_code()
# we execute the main dll, passing the code as argument, and the name of the low level code file to save the assembly instructions

res = self.my_c_dll.Compile(
create_string_buffer(self.low_level_code_file),
create_string_buffer(self.code.encode("utf-8")),
c_int(self.use_half),
c_int(self.use_fast_math),
c_int(self.device_id),
create_string_buffer(
(custom_cuda_include_fp16_path() + os.path.sep).encode("utf-8")
),
)
if os.name != "nt":
res = self.my_c_dll.Compile(
create_string_buffer(self.low_level_code_file),
create_string_buffer(self.code.encode("utf-8")),
c_int(self.use_half),
c_int(self.use_fast_math),
c_int(self.device_id),
create_string_buffer(
(custom_cuda_include_fp16_path() + os.path.sep).encode("utf-8")
),
)
else:
res = self.my_c_dll.Compile(
create_string_buffer(self.low_level_code_file),
create_string_buffer(self.code.encode("utf-8")),
c_int(self.use_half),
c_int(self.device_id),
create_string_buffer(
(custom_cuda_include_fp16_path() + os.path.sep).encode("utf-8")
),
)
if res != 0:
KeOps_Error(
f"Error when compiling formula (error in nvrtcCompileProgram, nvrtcResult={res})"
Expand Down Expand Up @@ -116,8 +132,14 @@ def get_compile_command(
@staticmethod
def compile_jit_compile_dll():
KeOps_Message("Compiling cuda jit compiler engine ... ", flush=True, end="")
command = Gpu_link_compile.get_compile_command(
sourcename=jit_compile_src, dllname=jit_compile_dll()
)
KeOps_OS_Run(command)
if os.name == "nt":
from ...windows_compilations import compile_nvrtc_jit

compile_nvrtc_jit(build_folder=build_folder)
else:
command = Gpu_link_compile.get_compile_command(
sourcename=jit_compile_src, dllname=jit_compile_dll()
)
KeOps_OS_Run(command)

KeOps_Message("OK", use_tag=False, flush=True)
Loading