Skip to content

Commit cbe08d0

Browse files
committed
updating pocl and formating scripts
1 parent a8744ed commit cbe08d0

File tree

7 files changed

+297
-80
lines changed

7 files changed

+297
-80
lines changed

build_vortex.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,44 @@
66

77
def run_command(command, cwd=None):
88
print(f"Running command: {command}")
9-
result = subprocess.run(command, shell=True, cwd=cwd, executable='/bin/bash')
9+
result = subprocess.run(command, shell=True, cwd=cwd, executable="/bin/bash")
1010
if result.returncode != 0:
1111
print(f"Command failed with return code {result.returncode}")
1212
sys.exit(result.returncode)
1313

14+
1415
def main():
1516
project_root = os.path.dirname(os.path.abspath(__file__))
16-
1717

1818
vortex_source_dir = os.path.join(project_root, "deps/vortex")
1919
pocl_source_dir = os.path.join(project_root, "deps/pocl")
20-
20+
2121
vortex_build_dir = os.path.join(vortex_source_dir, "build")
2222
tool_dir = os.path.join(project_root, "vortex-tools")
2323
pocl_tool_path = os.path.join(tool_dir, "pocl")
24-
24+
2525
os.makedirs(vortex_build_dir, exist_ok=True)
2626
os.makedirs(tool_dir, exist_ok=True)
2727
if os.path.exists(pocl_tool_path):
2828
shutil.rmtree(pocl_tool_path)
29-
29+
3030
vortex_source_rel_to_build = os.path.relpath(vortex_source_dir, vortex_build_dir)
3131
pocl_source_rel_to_build = os.path.relpath(pocl_source_dir, vortex_build_dir)
3232
tool_dir_rel_to_build = os.path.relpath(tool_dir, vortex_build_dir)
3333

34-
3534
configure_cmd = (
3635
f"{vortex_source_rel_to_build}/configure --xlen=64 --tooldir={tool_dir} && "
3736
f"TOOLDIR={tool_dir_rel_to_build} ./ci/toolchain_install.sh --all"
3837
)
3938
run_command(configure_cmd, cwd=vortex_build_dir)
4039

41-
42-
build_cmd = (
43-
f"source {vortex_build_dir}/ci/toolchain_env.sh && make -s"
44-
)
40+
build_cmd = f"source {vortex_build_dir}/ci/toolchain_env.sh && make -s"
4541
run_command(build_cmd, cwd=vortex_build_dir)
4642

47-
4843
pocl_build_script_path = os.path.join(vortex_build_dir, "build_pocl.sh")
4944
with open(pocl_build_script_path, "w") as f:
50-
f.write(f"""
45+
f.write(
46+
f"""
5147
#!/bin/bash
5248
set -ex
5349
echo "--- Building POCL for Vortex ---"
@@ -63,12 +59,14 @@ def main():
6359
make install
6460
cp -r ../include "$POCL_PATH"
6561
echo "--- POCL build finished ---"
66-
""")
67-
62+
"""
63+
)
64+
6865
os.chmod(pocl_build_script_path, 0o755)
6966
run_command("./build_pocl.sh", cwd=vortex_build_dir)
7067

7168
print("--- Vortex and POCL build finished successfully! ---")
7269

70+
7371
if __name__ == "__main__":
7472
main()

configure_vortex.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import subprocess
33

4+
45
def main():
56
parser = argparse.ArgumentParser()
67
parser.add_argument("--vortex-dir", help="path to vortex directory")
@@ -9,39 +10,48 @@ def main():
910
parser.add_argument("--cores", help="count of cores")
1011
parser.add_argument("--threads", help="count of threads", type=int, default=4)
1112
parser.add_argument("--clusters", help="count of clusters")
12-
args=parser.parse_args()
13-
vortex_config_args= [f"{args.vortex_dir}/build/ci/blackbox.sh","--app=opencl/vecadd"]
13+
parser.add_argument("--l2cache", help="l2cache")
14+
parser.add_argument("--l3cache", help="l3cache")
15+
args = parser.parse_args()
16+
vortex_config_args = [
17+
f"{args.vortex_dir}/build/ci/blackbox.sh",
18+
"--app=opencl/vecadd",
19+
]
1420
if args.driver:
15-
vortex_config_args+= [f"--driver={args.driver}"]
21+
vortex_config_args += [f"--driver={args.driver}"]
1622
if args.warps:
17-
vortex_config_args+= [f"--warps={args.warps}"]
23+
vortex_config_args += [f"--warps={args.warps}"]
1824
if args.cores:
19-
vortex_config_args+= [f"--cores={args.cores}"]
25+
vortex_config_args += [f"--cores={args.cores}"]
2026
if args.threads:
21-
vortex_config_args+= [f"--threads={args.threads}"]
27+
vortex_config_args += [f"--threads={args.threads}"]
2228
if args.clusters:
23-
vortex_config_args+= [f"--clusters={args.clusters}"]
24-
result=subprocess.run(vortex_config_args,
25-
capture_output=True, text=True)
26-
export_line=None
27-
if result.returncode!=0:
29+
vortex_config_args += [f"--clusters={args.clusters}"]
30+
if args.l2cache:
31+
if int(args.l2cache) == 1:
32+
vortex_config_args += [f"--l2cache"]
33+
if args.l3cache:
34+
if int(args.l3cache) == 1:
35+
vortex_config_args += [f"--l3cache"]
36+
result = subprocess.run(
37+
vortex_config_args, capture_output=True, text=True, timeout=55.0
38+
)
39+
export_line = None
40+
if result.returncode != 0:
2841
return
2942
for line in result.stdout.split("\n"):
3043
if line.startswith("LD_LIBRARY_PATH="):
31-
export_line=line
44+
export_line = line
3245
break
3346
if line.startswith("SCOPE_JSON_PATH="):
34-
export_line=line
47+
export_line = line
3548
break
3649

3750
if export_line is None:
38-
return
39-
40-
print(f"export {" ".join(export_line.split()[:-2])}")
41-
42-
51+
return
4352

53+
print(f"export {" ".join(export_line.split()[:-2])}")
4454

4555

46-
if __name__ == '__main__':
47-
main()
56+
if __name__ == "__main__":
57+
main()

deps/pocl/lib/CL/devices/vortex/pocl-vortex.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pocl_vortex_init (unsigned j, cl_device_id dev, const char* parameters)
161161
}
162162

163163
dev->vendor = "Vortex Group";
164-
dev->long_name = "Vortex OpenGPU";
165164
dev->short_name = "Vortex";
166165
dev->vendor_id = 0;
167166
dev->type = CL_DEVICE_TYPE_GPU;
@@ -236,6 +235,15 @@ pocl_vortex_init (unsigned j, cl_device_id dev, const char* parameters)
236235
free(dd);
237236
return CL_DEVICE_NOT_FOUND;
238237
}
238+
char* long_name = (char *)malloc(64 * sizeof(char));
239+
if (long_name == NULL)
240+
{
241+
vx_dev_close(vx_device);
242+
free(dd);
243+
return CL_OUT_OF_HOST_MEMORY;
244+
}
245+
snprintf(long_name, 64 * sizeof(char), "Vortex OpenGPU W%luT%lu", num_warps, num_threads);
246+
dev->long_name = long_name;
239247

240248
uint64_t max_work_group_size = num_warps * num_threads;
241249

@@ -283,9 +291,9 @@ cl_int pocl_vortex_uninit (unsigned j, cl_device_id dev) {
283291

284292
int pocl_vortex_init_context (cl_device_id dev, cl_context context) {
285293
vortex_device_data_t *dd = (vortex_device_data_t *)dev->data;
286-
if (NULL == dd) {
287-
pocl_vortex_init(0, dev, NULL);
288-
dd = (vortex_device_data_t*) dev->data;
294+
if (dd == NULL){
295+
pocl_vortex_init(0,dev,NULL);
296+
dd = (vortex_device_data_t *)dev->data;
289297
}
290298

291299
dd->ctx_refcount++;
@@ -310,7 +318,6 @@ int pocl_vortex_post_build_program (cl_program program, cl_uint device_i) {
310318
cl_device_id dev = program->devices[device_i];
311319
vortex_device_data_t *ddata = (vortex_device_data_t *)dev->data;
312320
vortex_program_data_t *pdata = NULL;
313-
314321
POCL_LOCK (ddata->compile_lock);
315322

316323
do {
@@ -580,6 +587,7 @@ void pocl_vortex_run (void *data, _cl_command_node *cmd) {
580587
// release previous kernel buffer
581588
if (dd->vx_kernel_buffer != NULL)
582589
{
590+
vx_dump_perf(dd->vx_device, stdout);
583591
vx_mem_free(dd->vx_kernel_buffer);
584592
dd->vx_kernel_buffer = NULL;
585593
}
@@ -757,8 +765,8 @@ void pocl_vortex_submit (_cl_command_node *node, cl_command_queue cq) {
757765

758766
void pocl_vortex_flush (cl_device_id dev, cl_command_queue cq) {
759767
vortex_device_data_t *dd = (vortex_device_data_t *)dev->data;
760-
if (dd == NULL)
761-
return;
768+
if(dd == NULL)
769+
return;
762770
POCL_LOCK (dd->cq_lock);
763771
vortex_command_scheduler (dd);
764772
POCL_UNLOCK (dd->cq_lock);

0 commit comments

Comments
 (0)