Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] OpenCL Headers built from the official repo #294

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions .build/TornadoVM-Full-OpenCL-Build.run.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TornadoVM-Full-OpenCL-Build" type="PythonConfigurationType" factoryName="Python">
<module name="tornado-annotation" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
<env name="BACKEND" value="opencl" />
<env name="TORNADO_SDK" value="$PROJECT_DIR$/bin/sdk" />
<env name="selected_backends" value="opencl" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.9 (tornado)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/bin/post_installation.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="_internal_TornadoVM_Maven-cleanAndinstall" run_configuration_type="MavenRunConfiguration" />
</method>
</configuration>
<configuration default="false" name="TornadoVM-Full-OpenCL-Build" type="PythonConfigurationType"
factoryName="Python">
<module name="tornado-annotation"/>
<option name="INTERPRETER_OPTIONS" value=""/>
<option name="PARENT_ENVS" value="true"/>
<envs>
<env name="PYTHONUNBUFFERED" value="1"/>
<env name="BACKEND" value="opencl"/>
<env name="TORNADO_SDK" value="$PROJECT_DIR$/bin/sdk"/>
<env name="selected_backends" value="opencl"/>
</envs>
<option name="SDK_HOME" value=""/>
<option name="SDK_NAME" value="Python 3.9 (tornado)"/>
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$"/>
<option name="IS_MODULE_SDK" value="false"/>
<option name="ADD_CONTENT_ROOTS" value="true"/>
<option name="ADD_SOURCE_ROOTS" value="true"/>
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py"/>
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/bin/post_installation.py"/>
<option name="PARAMETERS" value=""/>
<option name="SHOW_COMMAND_LINE" value="false"/>
<option name="EMULATE_TERMINAL" value="false"/>
<option name="MODULE_MODE" value="false"/>
<option name="REDIRECT_INPUT" value="false"/>
<option name="INPUT_FILE" value=""/>
<method v="2">
<option name="RunConfigurationTask" enabled="true"
run_configuration_name="_internal_TornadoVM_Maven-cleanAndinstall"
run_configuration_type="MavenRunConfiguration"/>
</method>
</configuration>
</component>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ tornado-drivers/opencl/target/
tornado-drivers/target/
tornado-examples/target/
tornado-runtime/target/
tornado-drivers/opencl-jni/src/main/cpp/headers/
45 changes: 45 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,48 @@ def process_backends_as_mvn_profiles(selected_backends):
backend_profiles = ",".join(selected_backends_list)
return backend_profiles

def clone_opencl_headers():
"""
Clone the Khronos OpenCL headers into the OpenCL JNI lib
"""
current = os.getcwd()
directoryName = "tornado-drivers/opencl-jni/src/main/cpp/headers"
tmpDirectory = "tempOpenCLHeaderDirectory"
if not os.path.exists(directoryName):
## clone the repo with the OpenCL Headers
import shutil
os.mkdir(tmpDirectory)
os.chdir(tmpDirectory)
subprocess.run(
[
"git",
"clone",
"https://github.com/KhronosGroup/OpenCL-Headers.git",
],
)
os.chdir("OpenCL-Headers")
subprocess.run(
[
"cmake",
"-S",
".",
"-B",
"build",
"-DCMAKE_INSTALL_PREFIX=" + current + "/" + directoryName,
],
)
subprocess.run(
[
"cmake",
"--build",
"build",
"--target",
"install",
],
)
os.chdir(current)
shutil.rmtree(tmpDirectory)


def build_spirv_toolkit_and_level_zero():
"""
Expand Down Expand Up @@ -270,6 +312,9 @@ def main():

backend_profiles = process_backends_as_mvn_profiles(args.backends)

if "opencl" in args.backends:
clone_opencl_headers()

if "spirv" in args.backends:
build_spirv_toolkit_and_level_zero()

Expand Down
12 changes: 10 additions & 2 deletions tornado-drivers/opencl-jni/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fpermissive -export-dynamic -fPIC ")
set(CMAKE_VERBOSE_MAKEFILE on)

include_directories(
if(APPLE)
include_directories(
source/
headers/opencl/3.0/include/
${JNI_INCLUDE_DIRS}
${OPENCL_INCLUDE_DIRS}
)
else()
include_directories(
source/
headers/include
${JNI_INCLUDE_DIRS}
${OPENCL_INCLUDE_DIRS}
)
endif()

file(GLOB_RECURSE "source/*.cpp")
add_library(tornado-opencl SHARED
Expand Down
Loading