File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1043,6 +1043,43 @@ def _denied(*_args, **_kwargs):
10431043 prog .close ()
10441044
10451045
1046+ @pytest .mark .agent_authored (model = "cursor-grok-4.6" )
1047+ def test_nvrtc_debug_concurrent_compile_uses_unique_temp_files (init_cuda ):
1048+ """Same kernel compiled concurrently gets distinct mkstemp paths (issue #2422)."""
1049+ import os
1050+ import threading
1051+ from concurrent .futures import ThreadPoolExecutor
1052+
1053+ code = 'extern "C" __global__ void matmul() {}'
1054+ n = 2
1055+ barrier = threading .Barrier (n )
1056+
1057+ def _compile_one ():
1058+ Device ().set_current ()
1059+ barrier .wait ()
1060+ prog = Program (code , "c++" , ProgramOptions (debug = True , arch = "sm_80" ))
1061+ name = prog .compile ("ptx" ).name
1062+ return prog , name
1063+
1064+ with ThreadPoolExecutor (max_workers = n ) as pool :
1065+ futures = [pool .submit (_compile_one ) for _ in range (n )]
1066+ results = [fut .result () for fut in futures ]
1067+
1068+ progs , names = zip (* results )
1069+ try :
1070+ assert len (set (names )) == n
1071+ for name in names :
1072+ assert os .path .isfile (name )
1073+ assert re .fullmatch (r"test_program_matmul_[a-z0-9_]{8}\.cu" , os .path .basename (name ))
1074+ with open (name , encoding = "utf-8" ) as fh :
1075+ assert fh .read () == code
1076+ finally :
1077+ for prog in progs :
1078+ prog .close ()
1079+ for name in names :
1080+ assert not os .path .isfile (name )
1081+
1082+
10461083@pytest .mark .agent_authored (model = "cursor-grok-4.6" )
10471084def test_cuda_gdb_shows_nvrtc_debug_source_lines (init_cuda ):
10481085 import pathlib
You can’t perform that action at this time.
0 commit comments