Skip to content
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
2 changes: 1 addition & 1 deletion buildbot/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def do_compile(args):
if cpu_count is None:
cpu_count = DEFAULT_CPU_COUNT

make_cmd = ["ninja", "-j", str(cpu_count), "deploy-sycl-toolchain", "opencl-aot"]
make_cmd = ["ninja", "-j", str(cpu_count), "deploy-sycl-toolchain", "deploy-opencl-aot"]
print(make_cmd)

subprocess.check_call(make_cmd, cwd=args.obj_dir)
Expand Down
47 changes: 39 additions & 8 deletions opencl-aot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

if(OpenCL_INCLUDE_DIR AND OpenCL_LIBRARY)
find_package(OpenCL)
endif()

include(ExternalProject)

if (NOT OpenCL_INCLUDE_DIRS)
Expand All @@ -22,6 +26,7 @@ if (NOT OpenCL_INCLUDE_DIRS)
COMMENT "Downloading OpenCL headers."
)
else ()
message("Copying OpenCL headers...")
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for notification about copying headers/ICD on configure step. Should it be removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's confusing. If I understand correctly headers are not copied during build files configuration. It looks like some debug messages...
I think it's better to remove or rephrase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created PR #959 with fix

add_custom_target(opencl-headers ALL
DEPENDS ${OpenCL_INCLUDE_DIRS}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${CMAKE_CURRENT_BINARY_DIR}/inc/CL
Expand Down Expand Up @@ -57,6 +62,7 @@ if (NOT OpenCL_LIBRARIES)
BUILD_BYPRODUCTS ${OpenCL_LIBRARIES}
)
else ()
message("Copying OpenCL ICD Loader...")
file(GLOB ICD_LOADER_SRC "${OpenCL_LIBRARIES}*")
file(COPY ${ICD_LOADER_SRC} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(opencl-icd DEPENDS ${OpenCL_LIBRARIES} COMMENT "Copying OpenCL ICD Loader ...")
Expand All @@ -66,20 +72,45 @@ set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Support
)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/OpenCL/inc
${CMAKE_CURRENT_SOURCE_DIR}/include
include_directories(${CMAKE_CURRENT_BINARY_DIR}/inc
${CMAKE_CURRENT_SOURCE_DIR}/include
)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB TARGET_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)

add_llvm_tool(opencl-aot ${TARGET_SOURCES})
set(OPENCL_AOT_PROJECT_NAME opencl-aot)

add_llvm_tool(${OPENCL_AOT_PROJECT_NAME} ${TARGET_SOURCES})

add_dependencies(${OPENCL_AOT_PROJECT_NAME} opencl-headers opencl-icd)

target_link_libraries(${OPENCL_AOT_PROJECT_NAME} PRIVATE OpenCL)

add_dependencies(opencl-aot opencl-headers opencl-icd)
# Use it as fake dependency in order to force another command(s) to execute.
add_custom_command(OUTPUT __force_it
COMMAND "${CMAKE_COMMAND}" -E echo
)
#Serialize installation to avoid missing components due to build race conditions
set(__chain_dep __force_it)

set(manifest_list)

target_link_libraries(opencl-aot PRIVATE OpenCL)
message( STATUS "Adding component ${OPENCL_AOT_PROJECT_NAME} to deploy")

set (manifest_file ${CMAKE_CURRENT_BINARY_DIR}/install_manifest_${OPENCL_AOT_PROJECT_NAME}.txt)
add_custom_command(OUTPUT ${manifest_file}
COMMAND "${CMAKE_COMMAND}"
"-DCMAKE_INSTALL_COMPONENT=${OPENCL_AOT_PROJECT_NAME}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
DEPENDS ${__chain_dep}
COMMENT "Deploying component ${OPENCL_AOT_PROJECT_NAME}"
USES_TERMINAL
)
list(APPEND manifest_list ${manifest_file})
set(__chain_dep ${manifest_file})

install(FILES ${CMAKE_BINARY_DIR}/bin/opencl-aot${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION bin
COMPONENT opencl-aot
add_custom_target(deploy-${OPENCL_AOT_PROJECT_NAME}
DEPENDS ${OPENCL_AOT_PROJECT_NAME} ${manifest_list}
)
7 changes: 6 additions & 1 deletion sycl/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
tool_dirs = [config.llvm_tools_dir]
llvm_config.add_tool_substitutions(tools, tool_dirs)

if "opencl-aot" in config.llvm_enable_projects:
if 'PATH' in os.environ:
print("Adding path to opencl-aot tool to PATH")
os.environ['PATH'] = os.path.pathsep.join((os.getenv('PATH'), config.llvm_build_bins_dir))

get_device_count_by_type_path = os.path.join(config.llvm_binary_dir,
"bin", "get_device_count_by_type")

Expand Down Expand Up @@ -155,7 +160,7 @@ def getDeviceCount(device_type):
# so they need to be pre-installed on the machine
aot_tools = ["opencl-aot", "ocloc", "aoc"]
for aot_tool in aot_tools:
if find_executable(aot_tool) != None:
if find_executable(aot_tool) is not None:
print("Found AOT device compiler " + aot_tool)
config.available_features.add(aot_tool)
else:
Expand Down
2 changes: 2 additions & 0 deletions sycl/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ config.opencl_include = "@OPENCL_INCLUDE@"
config.sycl_include = "@SYCL_INCLUDE@"
config.sycl_obj_root = "@SYCL_BINARY_DIR@"

config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@"


import lit.llvm
lit.llvm.initialize(lit_config, config)
Expand Down