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

remove expensive preprocess for cache on Windows #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions pycuda/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ def preprocess_source(source, options, nvcc):
return preprocessed_str.replace(os.path.basename(source_path), "")


def compile_plain(source, options, keep, nvcc, cache_dir, target="cubin"):
def compile_plain(source, options, keep, nvcc, cache_dir, target="cubin", force_no_preprocess_checksum=False):
from os.path import join

assert target in ["cubin", "ptx", "fatbin"]

if cache_dir:
checksum = _new_md5()

if "#include" in source:
if not force_no_preprocess_checksum and "#include" in source:
checksum.update(preprocess_source(source, options, nvcc).encode("utf-8"))
else:
checksum.update(source.encode("utf-8"))
Expand Down Expand Up @@ -289,12 +289,13 @@ def compile(
elif "win32" in sys.platform and sys.maxsize == 2147483647:
options.append("-m32")

no_preprocess_checksum = "win32" in sys.platform and not include_dirs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this affects correctness, I would like the behavior to be strictly opt-in.

include_dirs = include_dirs + [_find_pycuda_include_path()]

for i in include_dirs:
options.append("-I" + i)

return compile_plain(source, options, keep, nvcc, cache_dir, target)
return compile_plain(source, options, keep, nvcc, cache_dir, target, no_preprocess_checksum)


class CudaModule:
Expand Down
Loading