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

Refactor OpenCL integration using maintained OpenCL C++ interface #60

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 10 additions & 2 deletions autoscoper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,19 @@ if(Autoscoper_RENDERING_BACKEND STREQUAL "CUDA")
)
elseif(Autoscoper_RENDERING_BACKEND STREQUAL "OpenCL")
find_package(OpenCL ${Autoscoper_OpenCL_MINIMUM_REQUIRED_VERSION} REQUIRED)
target_include_directories(autoscoper PUBLIC ${OPENCL_INCLUDE_DIRS})
find_package(OpenCLHeaders REQUIRED)
find_package(OpenCLHeadersCpp REQUIRED)
#target_include_directories(autoscoper PUBLIC ${OPENCL_INCLUDE_DIRS})
set(GPU_LIBRARIES
${OpenCL_LIBRARIES}
OpenCL::HeadersCpp
)
target_compile_definitions(autoscoper PRIVATE
CL_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_MINIMUM_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_ENABLE_EXCEPTIONS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They may want to disable this and only rely on error checking (at least while we are refactoring the Autoscoper API)

)
target_compile_definitions(autoscoper PRIVATE CL_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION})
else()
message(FATAL_ERROR "Setting Autoscoper_RENDERING_BACKEND to '${Autoscoper_RENDERING_BACKEND}' is not supported")
endif()
Expand Down
14 changes: 12 additions & 2 deletions libautoscoper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ if(Autoscoper_RENDERING_BACKEND STREQUAL "CUDA")
target_include_directories(libautoscoper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/cuda/cutil)
elseif(Autoscoper_RENDERING_BACKEND STREQUAL "OpenCL")
find_package(OpenCL ${Autoscoper_OpenCL_MINIMUM_REQUIRED_VERSION} REQUIRED)
find_package(OpenCLHeaders REQUIRED)
find_package(OpenCLHeadersCpp REQUIRED)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/opencl/CMakeLists.txt)
add_library(libautoscoper STATIC ${libautoscoper_SOURCES} ${libautoscoper_HEADERS} ${opencl_SOURCES} ${opencl_HEADERS})
target_include_directories(libautoscoper PUBLIC ${OpenCL_INCLUDE_DIRS})
#target_include_directories(libautoscoper PUBLIC ${OpenCL_INCLUDE_DIRS})
add_dependencies(libautoscoper ${SHADER_TO_HEADER})
target_compile_definitions(libautoscoper PRIVATE CL_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION})
target_link_libraries(libautoscoper PUBLIC
OpenCL::HeadersCpp
)
target_compile_definitions(libautoscoper PRIVATE
CL_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_TARGET_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_MINIMUM_OPENCL_VERSION=${Autoscoper_CL_TARGET_OPENCL_VERSION}
CL_HPP_ENABLE_EXCEPTIONS
)
else()
message(FATAL_ERROR "Setting Autoscoper_RENDERING_BACKEND to '${Autoscoper_RENDERING_BACKEND}' is not supported")
endif()
Expand Down
13 changes: 2 additions & 11 deletions libautoscoper/src/gpu/opencl/OpenCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,11 @@
#ifndef XROMM_HPP
#define XROMM_HPP

#include <CL/opencl.hpp>

#include <iostream>
#include <vector>

#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/opencl.h>
#include <OpenGL/OpenGL.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <CL/opencl.h>
#include <GL/gl.h>
#endif

namespace xromm { namespace gpu {

void opencl_global_gl_context();
Expand Down