-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_cl_structs.py
More file actions
32 lines (24 loc) · 1.03 KB
/
fix_cl_structs.py
File metadata and controls
32 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import glob
pc_struct = """typedef struct {
uint stride;
uint mask;
uint iterations;
uint padding;
} PushConstants;
"""
for f in glob.glob("kernels/opencl/*.cl"):
with open(f, 'r') as file:
content = file.read()
if content.find("PushConstants pc") != -1: continue
content = pc_struct + content
content = content.replace("uint4 pc", "PushConstants pc")
content = content.replace("pc.x", "pc.stride")
content = content.replace("pc.y", "pc.mask")
content = content.replace("pc.z", "pc.iterations")
# If it was still completely without pc, fix that too:
if "run_benchmark(__global uint* data)" in content:
content = content.replace("run_benchmark(__global uint* data)", "run_benchmark(__global uint* data, PushConstants pc)")
if "run_benchmark(__global float4* data)" in content:
content = content.replace("run_benchmark(__global float4* data)", "run_benchmark(__global float4* data, PushConstants pc)")
with open(f, 'w') as file:
file.write(content)