hipify fix
Browse files
backend/tools/hipify_wrapper.py
CHANGED
|
@@ -30,7 +30,15 @@ class HipifyWrapper:
|
|
| 30 |
["hipify-clang", "--version"],
|
| 31 |
capture_output=True, timeout=5, check=False
|
| 32 |
)
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
except (OSError, subprocess.SubprocessError):
|
| 35 |
return False
|
| 36 |
|
|
@@ -41,10 +49,9 @@ class HipifyWrapper:
|
|
| 41 |
f.write(cuda_code)
|
| 42 |
tmp_path = f.name
|
| 43 |
|
| 44 |
-
#
|
| 45 |
-
#
|
| 46 |
-
cmd = ["hipify-clang", tmp_path, "--"
|
| 47 |
-
"-nocudalib", "-nocudainc"]
|
| 48 |
|
| 49 |
# Debug log for build engineering
|
| 50 |
print(f"DEBUG: Running hipify-clang command: {' '.join(cmd)}")
|
|
|
|
| 30 |
["hipify-clang", "--version"],
|
| 31 |
capture_output=True, timeout=5, check=False
|
| 32 |
)
|
| 33 |
+
if result.returncode != 0:
|
| 34 |
+
return False
|
| 35 |
+
# Skip if no usable CUDA headers — hipify-clang will fail anyway
|
| 36 |
+
cuda_header_paths = [
|
| 37 |
+
"/usr/local/cuda/include/cuda_runtime.h",
|
| 38 |
+
"/usr/lib/cuda/include/cuda_runtime.h",
|
| 39 |
+
"/opt/cuda/include/cuda_runtime.h",
|
| 40 |
+
]
|
| 41 |
+
return any(os.path.exists(p) for p in cuda_header_paths)
|
| 42 |
except (OSError, subprocess.SubprocessError):
|
| 43 |
return False
|
| 44 |
|
|
|
|
| 49 |
f.write(cuda_code)
|
| 50 |
tmp_path = f.name
|
| 51 |
|
| 52 |
+
# -nocudalib and -nocudainc are hipify-clang tool flags — must come BEFORE
|
| 53 |
+
# the -- separator (flags after -- go to the internal Clang parser, not the tool).
|
| 54 |
+
cmd = ["hipify-clang", "-nocudalib", "-nocudainc", tmp_path, "--"]
|
|
|
|
| 55 |
|
| 56 |
# Debug log for build engineering
|
| 57 |
print(f"DEBUG: Running hipify-clang command: {' '.join(cmd)}")
|