Skip to content

Commit 9cb22fe

Browse files
committed
remove expensive preprocess for cache on Windows
add force_no_preprocess_checksum option for compile_plain enable it on Windows when include_dirs is empty
1 parent 96aab3f commit 9cb22fe

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pycuda/compiler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ def preprocess_source(source, options, nvcc):
7878
return preprocessed_str.replace(os.path.basename(source_path), "")
7979

8080

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

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

8686
if cache_dir:
8787
checksum = _new_md5()
8888

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

292+
no_preprocess_checksum = "win32" in sys.platform and not include_dirs
292293
include_dirs = include_dirs + [_find_pycuda_include_path()]
293294

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

297-
return compile_plain(source, options, keep, nvcc, cache_dir, target)
298+
return compile_plain(source, options, keep, nvcc, cache_dir, target, no_preprocess_checksum)
298299

299300

300301
class CudaModule:

0 commit comments

Comments
 (0)