diff --git a/buildbot/compile.py b/buildbot/compile.py index ba1ac5c14e2ba..91df61ed4510d 100644 --- a/buildbot/compile.py +++ b/buildbot/compile.py @@ -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) diff --git a/opencl-aot/CMakeLists.txt b/opencl-aot/CMakeLists.txt index 69e2db8a8afc5..340fc95e5dfbf 100644 --- a/opencl-aot/CMakeLists.txt +++ b/opencl-aot/CMakeLists.txt @@ -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) @@ -22,6 +26,7 @@ if (NOT OpenCL_INCLUDE_DIRS) COMMENT "Downloading OpenCL headers." ) else () + message("Copying OpenCL headers...") 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 @@ -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 ...") @@ -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} ) diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index fdf57998eabc5..e4e13e8dc5f56 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -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") @@ -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: diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index 6f084b6428a96..7205b06a96e7e 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -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)