Skip to content
Snippets Groups Projects

WIP: Opencl to SPIR-V ahead-of-time compilation

Closed Stephan Seitz requested to merge seitz/pystencils:opencl-to-spirv into master
Viewing commit a1f4f965
Show latest version
1 file
+ 10
15
Preferences
Compare changes
+ 10
15
@@ -66,8 +66,10 @@ def _opencl_to_spriv(opencl_code,
f.write(code)
if opencl_output_file:
shutil.copy(cl_file, opencl_output_file)
spirv_opt = shutil.which('spirv-opt')
if spirv_compiler == 'clspv':
# You can pass -cl-std=CLC++ to clspv to compile C++ for OpenCL (you wil also need -inline-entry-points)
assert 0 == call(['clspv',
*OCL_FAST_MATH_FLAGS,
*(['-cl-single-precision-constant'] if silence_warnings else []),
@@ -83,17 +85,10 @@ def _opencl_to_spriv(opencl_code,
if code_as_c_array:
raise("Output as C-array only supported with clspv")
clang = get_clang_command()
if not clang:
raise('Could not find clang!')
llvm_spirv = shutil.which('llvm-spirv')
if not llvm_spirv:
raise('Could not find llvm-spirv!')
spirv_opt = shutil.which('spirv-opt')
if not spirv_opt:
raise('Could not find llvm-opt!')
assert 0 == call([clang,
'-cc1', # or cc1?
'-cc1',
'-x', 'cl',
'-triple', 'spir',
f"-cl-std=CL{opencl_version}",
@@ -105,15 +100,15 @@ def _opencl_to_spriv(opencl_code,
'-o',
llvm_file])
assert 0 == call([llvm_spirv,
llvm_file, # or cc1?
llvm_file,
'-o',
spirv_file])
assert 0 == call([spirv_opt,
spirv_file, # or cc1?
'-o',
output_file])
assert isfile(spirv_file)
shutil.copy(spirv_file, output_file)
assert 0 == call([spirv_opt,
spirv_file,
'-o',
output_file])
assert isfile(output_file)
def _opencl_ast_to_spriv(ast,