aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/tools/cvt.py
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2020-08-03 01:42:13 +0200
committerAndrzej Janik <[email protected]>2020-08-03 01:42:13 +0200
commita10ee48e91dba08f4709d9e9928a530bec8e93bb (patch)
treeee256937eef0abfd3e90e4a12a80970139fa7bce /ptx/tools/cvt.py
parentff449289eb6fe4e429be25ef829ff10144146056 (diff)
downloadZLUDA-a10ee48e91dba08f4709d9e9928a530bec8e93bb.tar.gz
ZLUDA-a10ee48e91dba08f4709d9e9928a530bec8e93bb.zip
Add support for parsing instruction cvt
Diffstat (limited to 'ptx/tools/cvt.py')
-rw-r--r--ptx/tools/cvt.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/ptx/tools/cvt.py b/ptx/tools/cvt.py
new file mode 100644
index 0000000..ab6e5ce
--- /dev/null
+++ b/ptx/tools/cvt.py
@@ -0,0 +1,36 @@
+import os
+import subprocess
+import tempfile
+
+types = ["u8", "u16", "u32", "u64", "s8", "s16", "s32", "s64", "f16", "f32", "f64"]
+rnd = ["", ".rn", ".rni"]
+ftz_all = ["", ".ftz"]
+sat = ["", ".sat"]
+
+for in_type in types:
+ for out_type in types:
+ for r in rnd:
+ for ftz in ftz_all:
+ for s in sat:
+ with tempfile.TemporaryDirectory() as dir:
+ f_name = os.path.join(dir, 'ptx')
+ out_name = os.path.join(dir, 'out')
+ with open(f_name, 'w') as f:
+ f.write(
+ f"""
+ .version 6.5
+ .target sm_30
+ .address_size 64
+ .visible .entry VecAdd_kernel()
+ {{
+ .reg.{in_type} r1;
+ .reg.{out_type} r2;
+ cvt{r}{ftz}{s}.{out_type}.{in_type} r2, r1;
+ ret;
+ }}
+ """)
+ err = subprocess.run(f"ptxas {f_name} -o {out_name}", capture_output = True)
+ if err.returncode == 0:
+ print(f"cvt{r}{ftz}{s}.{out_type}.{in_type}")
+ #else:
+ # print(f"[INVALID] cvt{r}{ftz}{s}.{out_type}.{in_type}") \ No newline at end of file