Skip to content

Commit

Permalink
Merge pull request #88 from frasercrmck/remove-materialize-absent-wis
Browse files Browse the repository at this point in the history
[compiler] Remove MaterializeAbsentWorkItemBuiltinsPass
  • Loading branch information
frasercrmck authored Aug 15, 2023
2 parents f2e1c93 + 91f179d commit e9caf3d
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 207 deletions.
31 changes: 0 additions & 31 deletions doc/modules/compiler/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,37 +549,6 @@ first string argument.
This pass is not useful when doing ahead-of-time compilation, when many
kernels may be in the same module.

MaterializeAbsentWorkItemBuiltinsPass
-------------------------------------

This pass links builtins into the module which are not added in the
`LinkBuiltinsPass`_.

In the case that we built an OpenCL 1.2 driver, certain OpenCL 2.X builtins and
their ``__mux`` variants will not be present in the builtins module. These include:

* ``size_t get_global_linear_id()``
* ``size_t get_local_linear_id()``
* ``size_t get_enqueued_local_size(uint)``

However, when consuming SPIR-V calls to these builtins can still appear as a
result of the SPIR-V variables: ``GlobalLinearId``, ``LocalInvocationIndex``
and ``EnqueuedWorkgroupSize`` (respectively), even on an OpenCL 1.2 driver.

In this case the ``MaterializeAbsentWorkItemBuiltinsPass`` pass provides
definitions of these functions in terms of ``__mux`` builtins that are
themselves defined later down the compilation pipeline in the
`DefineMuxBuiltinsPass`_ pass.

The reasoning behind doing this in the compiler is to avoid leaking OpenCL 3.0
specific IP into an OpenCL 1.2 driver; only supporting these builtins on the
SPIR-V path so that an OpenCL 1.2 user won't be able to harness them in their
OpenCL C.

Note that for an OpenCL-3.0 driver, these builtins **will** be defined in terms
of ``__mux`` builtins in the module linked during the ``LinkBuiltinsPass``, so
in that case this pass is a no-op.

ReduceToFunctionPass
--------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <compiler/utils/link_builtins_pass.h>
#include <compiler/utils/lower_to_mux_builtins_pass.h>
#include <compiler/utils/make_function_name_unique_pass.h>
#include <compiler/utils/materialize_absent_work_item_builtins_pass.h>
#include <compiler/utils/metadata_analysis.h>
#include <compiler/utils/optimal_builtin_replacement_pass.h>
#include <compiler/utils/pipeline_parse_helpers.h>
Expand Down
2 changes: 0 additions & 2 deletions modules/compiler/source/base/source/base_pass_registry.def
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ MODULE_PASS("degenerate-sub-groups", compiler::utils::DegenerateSubGroupPass())
MODULE_PASS("link-builtins", compiler::utils::LinkBuiltinsPass())
MODULE_PASS("lower-to-mux-builtins", compiler::utils::LowerToMuxBuiltinsPass())

MODULE_PASS("missing-builtins",
compiler::utils::MaterializeAbsentWorkItemBuiltinsPass())
MODULE_PASS("prepare-barriers", compiler::utils::PrepareBarriersPass())
MODULE_PASS("rename-builtins", compiler::utils::RenameBuiltinsPass())
MODULE_PASS("replace-async-copies", compiler::utils::ReplaceAsyncCopiesPass())
Expand Down
3 changes: 0 additions & 3 deletions modules/compiler/source/base/source/pass_pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <compiler/utils/degenerate_sub_group_pass.h>
#include <compiler/utils/fixup_calling_convention_pass.h>
#include <compiler/utils/link_builtins_pass.h>
#include <compiler/utils/materialize_absent_work_item_builtins_pass.h>
#include <compiler/utils/optimal_builtin_replacement_pass.h>
#include <compiler/utils/prepare_barriers_pass.h>
#include <compiler/utils/reduce_to_function_pass.h>
Expand Down Expand Up @@ -70,8 +69,6 @@ void addLateBuiltinsPasses(ModulePassManager &PM,
const BasePassPipelineTuner &tuner) {
PM.addPass(compiler::utils::LinkBuiltinsPass());

PM.addPass(compiler::utils::MaterializeAbsentWorkItemBuiltinsPass());

PM.addPass(compiler::utils::DefineMuxDmaPass());

PM.addPass(compiler::utils::ReplaceMuxMathDeclsPass(
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion modules/compiler/test/lit/passes/pipeline-components.ll
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ target datalayout = "e-p:64:64:64-m:e-i64:64-f80:128-n8:16:32:64-S128"
; PRE-VECZ: Running pass: compiler::utils::PrepareBarriersPass

; LATE-BUILTINS: Running pass: compiler::utils::LinkBuiltinsPass
; LATE-BUILTINS: Running pass: compiler::utils::MaterializeAbsentWorkItemBuiltinsPass
; LATE-BUILTINS: Running pass: compiler::utils::DefineMuxDmaPass
; LATE-BUILTINS: Running pass: compiler::utils::ReplaceMuxMathDeclsPass
; LATE-BUILTINS: Running pass: compiler::utils::OptimalBuiltinReplacementPass
Expand Down
2 changes: 0 additions & 2 deletions modules/compiler/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ add_ca_library(compiler-utils STATIC
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/lower_to_mux_builtins_pass.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/make_function_name_unique_pass.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/mangling.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/materialize_absent_work_item_builtins_pass.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/memory_buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/metadata.h
${CMAKE_CURRENT_SOURCE_DIR}/include/compiler/utils/metadata_analysis.h
Expand Down Expand Up @@ -93,7 +92,6 @@ add_ca_library(compiler-utils STATIC
${CMAKE_CURRENT_SOURCE_DIR}/source/lower_to_mux_builtins_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/make_function_name_unique_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/mangling.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/materialize_absent_work_item_builtins_pass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/metadata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/metadata_analysis.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/metadata_hooks.cpp
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit e9caf3d

Please sign in to comment.