Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/sycl-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DLLVM_INSTALL_UTILS=ON \
-DNATIVECPU_USE_OCK=Off
-DNATIVECPU_USE_OCK=ON
- name: Compile
id: build
# Emulate default value for manual dispatch as we've run out of available arguments.
Expand Down
90 changes: 18 additions & 72 deletions llvm/lib/SYCLNativeCPUUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
set(OCK_LIBS)
option(NATIVECPU_USE_OCK "Use the oneAPI Construction Kit for Native CPU" ON)

# Don't use OCK compiler_passes if Native CPU is not enabled.
if(NOT "native_cpu" IN_LIST SYCL_ENABLE_BACKENDS)
set(NATIVECPU_USE_OCK Off CACHE BOOL "Use the oneAPI Construction Kit for Native CPU" FORCE)
endif()

if(NATIVECPU_USE_OCK)
add_subdirectory(compiler_passes EXCLUDE_FROM_ALL)
set(OCK_LIBS NativeCPUPipeline NativeCPUVecz)
endif()

add_llvm_component_library(LLVMSYCLNativeCPUUtils
PipelineSYCLNativeCPU.cpp
PrepareSYCLNativeCPU.cpp
Expand All @@ -17,80 +30,13 @@ add_llvm_component_library(LLVMSYCLNativeCPUUtils
TargetParser
TransformUtils
ipo
)
${OCK_LIBS}
)

option(NATIVECPU_USE_OCK "Use the oneAPI Construction Kit for Native CPU" ON)

# Don't fetch OCK if Native CPU is not enabled.
if(NOT "native_cpu" IN_LIST SYCL_ENABLE_BACKENDS)
set(NATIVECPU_USE_OCK Off CACHE BOOL "Use the oneAPI Construction Kit for Native CPU" FORCE)
endif()

if(NATIVECPU_USE_OCK)
set(OCK_SEARCH_LOC "oneapi-construction-kit/compiler_passes")
if(NOT FETCHCONTENT_SOURCE_DIR_ONEAPI-CK)
find_path(OCK_SOURCE_DIR ${OCK_SEARCH_LOC} PATHS ${CMAKE_PREFIX_PATH})
endif()
if(OCK_SOURCE_DIR)
message(STATUS "Found system source location of oneAPI Construction Kit in ${OCK_SOURCE_DIR}")
set(OCK_SOURCE_DIR "${OCK_SOURCE_DIR}/${OCK_SEARCH_LOC}")
set(OCK_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/oneapi-construction-kit")
else()
set(OCK_GIT_REPO "https://github.com/uxlfoundation/oneapi-construction-kit.git")
# commit d0a32d701e34b3285de7ce776ea36abfec673df7
# Merge: a9f848e0e8 56473a8c25
# Author: Harald van Dijk <[email protected]>
# Date: Mon Jun 30 12:24:46 2025 +0100
#
# Merge pull request #878 from hvdijk/specify-fuse-ld-lld
#
# [RefSi] Explicitly specify -fuse-ld=lld.
set(OCK_GIT_TAG d0a32d701e34b3285de7ce776ea36abfec673df7)

include(FetchContent)
FetchContent_Declare(oneapi-ck
GIT_REPOSITORY "${OCK_GIT_REPO}"
GIT_TAG "${OCK_GIT_TAG}"
)
FetchContent_GetProperties(oneapi-ck)
if(NOT oneapi-ck_POPULATED)
if(FETCHCONTENT_SOURCE_DIR_ONEAPI-CK)
message(STATUS "Using specified oneAPI Construction Kit repo location at ${FETCHCONTENT_SOURCE_DIR_ONEAPI-CK}")
else()
message(STATUS "Cloning oneAPI Construction Kit from ${OCK_GIT_REPO}, tag ${OCK_GIT_TAG}")
endif()
FetchContent_Populate(oneapi-ck)
message(STATUS "oneAPI Construction Kit cloned in ${oneapi-ck_SOURCE_DIR}")
set(OCK_SOURCE_DIR ${oneapi-ck_SOURCE_DIR}/compiler_passes)
set(OCK_BINARY_DIR ${oneapi-ck_BINARY_DIR})
endif()
endif()

set(CA_ENABLE_API "cl" CACHE STRING "" FORCE)
add_subdirectory(
${OCK_SOURCE_DIR}
${OCK_BINARY_DIR} EXCLUDE_FROM_ALL)

install(TARGETS compiler-pipeline
EXPORT;LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline
RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT compiler-pipeline)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS compiler-pipeline)
install(TARGETS vecz
EXPORT;LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz
RUNTIME DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT vecz)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS vecz)
install(TARGETS multi_llvm EXPORT;LLVMExports)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS multi_llvm)
target_compile_definitions(LLVMSYCLNativeCPUUtils PRIVATE NATIVECPU_USE_OCK)
target_include_directories(LLVMSYCLNativeCPUUtils PRIVATE
${oneapi-ck_SOURCE_DIR}/modules/compiler/multi_llvm/include
${oneapi-ck_SOURCE_DIR}/modules/cargo/include
${oneapi-ck_SOURCE_DIR}/modules/compiler/vecz/include
${oneapi-ck_SOURCE_DIR}/modules/compiler/utils/include)
target_link_libraries(LLVMSYCLNativeCPUUtils PRIVATE compiler-pipeline vecz)

endif()
${CMAKE_CURRENT_SOURCE_DIR}/compiler_passes/compiler_pipeline/include
${CMAKE_CURRENT_SOURCE_DIR}/compiler_passes/vecz/include)
endif()
2 changes: 2 additions & 0 deletions llvm/lib/SYCLNativeCPUUtils/compiler_passes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler_pipeline)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vecz)
64 changes: 64 additions & 0 deletions llvm/lib/SYCLNativeCPUUtils/compiler_passes/compiler_passes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Compiler passes
===============

Introduction
------------

Files under this directory are ported from the [oneAPI Construction
Kit](https://github.com/uxlfoundation/oneapi-construction-kit). They are used by
NativeCPU to help create a pipeline for turning a base kernel into something
which can be executed across multiple work items, including auto-vectorization.

These files are largely from the sub-directories
**modules/compiler/compiler_pipeline**, **modules/compiler/vecz** and
**modules/compiler/multi_llvm**. Only files that are used have been copied and
the **Cmake** files have been updated to fit in with LLVM components.

These sub-directories are used as follows:

* **compiler_pipeline** provides the passes to build a pipeline from the initial
kernel, including generating working item loops, handling local memory,
handling metadata and calling the vectorizer **vecz**.

* **vecz** provides a full function vectorizer, which generates a copy of the
original function but vectorized across the work group, taking into account
subgroups.

* **multi_llvm**. This provides some support for these functions to work across
multiple LLVM versions. Although this is not strictly needed in LLVM, it has
been ported across to allow the port to go smoothly, without changing files
directly. Note this is header only and exists under
**compiler_pipeline/include/multi_llvm**.

**compiler_pipeline** is documented in :doc:`/compiler_pipeline/docs/compiler`
and **vecz** is documented in :doc:`/vecz/vecz`. Note that there are several
limitations both in the documentation and in the code that are a result of the
initial port. These should be addressed.

General limitations
-------------------

There is the following limitations in the current port:

* The documentation makes a lot of references to **oneAPI Construction Kit**
constructs such as ComputeMux. It also references files that have not been
copied across.
* The namespace in **compiler_pipeline** is **compiler/utils**, the namespace in
multi_llvm is **multi_llvm** and the namespace in **vecz** is **vecz**. These should
be updated to reflect being under **LLVM**.
* include files should ideally be moved to under **llvm/include** but remain under
these directories after the port.
* **vecz** has a test tool **veczc** and associated **lit** tests. This tool if
required should be moved under **llvm/tools** or **llvm/test**. This is also not
built by default. It also refers to **@CA_COMMON_LIT_BINARY_PATH@** which is not
defined.
* **compiler_pipeline** has lit tests for the passes which have not been ported
across. This is because they use a tool **muxc**, but these passes should be
able to be tested using opt. These lit tests can be found
[here](https://github.com/uxlfoundation/oneapi-construction-kit/tree/main/modules/compiler/test/lit/passes).
* There are many files that are unlikely to have any code coverage but because
there are referred to in other files which we do need, they exist here. These
should be pruned over time as a better understanding is made of what is
required.

.. _oneAPI Construction Kit: https://github.com/uxlfoundation/oneapi-construction-kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
add_llvm_component_library(LLVMNativeCPUPipeline
${CMAKE_CURRENT_SOURCE_DIR}/source/attributes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/barrier_regions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/builtin_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/cl_builtin_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/define_mux_builtins_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/dma.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/encode_kernel_metadata_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/group_collective_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/mangling.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/metadata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/mux_builtin_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/pass_functions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/pass_machinery.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/prepare_barriers_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/replace_local_module_scope_variables_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/scheduling.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/sub_group_analysis.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/target_extension_types.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/work_item_loops_pass.cpp

LINK_COMPONENTS
Passes
Core
)

# TODO: Move to under LLVM include and work out why ADDITIONAL_HEADER_DIRS
# does not capture it.
target_include_directories(LLVMNativeCPUPipeline PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Compiler
========

.. toctree::
:maxdepth: 1

compiler/overview
compiler/utils
compiler/tools
Loading
Loading