Skip to content

Commit

Permalink
Update deps (#1232)
Browse files Browse the repository at this point in the history
Contributes to #1231

* Update llvm, spirv-headers, and spirv-tools
* Clang defines sqrt for float in opencl-c-base.h now
  * need to strip it to facilitate linking with cllib
  * need to always enable long vector lowering
    * xfail'd some tests for now
* Add missing dependency for header generation on opencl-c-base.h
  • Loading branch information
alan-baker authored Sep 14, 2023
1 parent 3e3c954 commit c0b1c96
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ add_custom_command(OUTPUT ${BAKE_FILE_OUTPUT_FILE}
--base-var=${BAKE_FILE_DATA_BASE_VARIABLE_NAME}
--base-size-var=${BAKE_FILE_SIZE_BASE_VARIABLE_NAME}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${BAKE_FILE_INPUT_FILE} ${BAKE_FILE_PYTHON_FILE}
DEPENDS ${BAKE_FILE_INPUT_FILE} ${BAKE_FILE_PYTHON_FILE} ${BAKE_FILE_BASE_HEADER_FILE}
)

add_custom_target(clspv_baked_opencl_header
Expand Down
6 changes: 3 additions & 3 deletions deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
"subrepo" : "llvm/llvm-project",
"branch" : "main",
"subdir" : "third_party/llvm",
"commit" : "76f20099a5ab72a261661ecb545dceed52e5592d"
"commit" : "c7d65e4466eafe518937c59ef9a242234ed7a08a"
},
{
"name" : "SPIRV-Headers",
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Headers",
"branch" : "main",
"subdir" : "third_party/SPIRV-Headers",
"commit" : "aa331ab0ffcb3a67021caa1a0c1c9017712f2f31"
"commit" : "fc7d2462765183c784a0c46beb13eee9e506a067"
},
{
"name" : "SPIRV-Tools",
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools",
"branch" : "main",
"subdir" : "third_party/SPIRV-Tools",
"commit" : "5d2bc6f064f00935dd552aa13afbff40e66458c5"
"commit" : "a996591b1c67e789e88e99ae3881272f5fc47374"
}
]
}
23 changes: 23 additions & 0 deletions lib/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "clspv/opencl_builtins_header.h"

#include "Builtins.h"
#include "BuiltinsEnum.h"
#include "Constants.h"
#include "FrontendPlugin.h"
#include "Passes.h"
Expand Down Expand Up @@ -1103,6 +1104,24 @@ ProgramToModule(llvm::LLVMContext &context,
return action.takeModule();
}

// Clang generates definitions for the following builtins:
// * sqrt
//
// These interfere with linking cllib builtins so we strip them.
// See https://reviews.llvm.org/D156743
// TODO(#1231): find a better solution for this.
void StripBuiltinDefinitions(llvm::Module *module) {
for (auto &F : module->functions()) {
if (F.isDeclaration())
continue;

const auto info = clspv::Builtins::Lookup(&F);
if (info.getType() == clspv::Builtins::kSqrt) {
F.deleteBody();
}
}
}

int CompileModule(const llvm::StringRef &input_filename,
std::unique_ptr<llvm::Module> &module,
std::vector<uint32_t> *output_buffer,
Expand Down Expand Up @@ -1146,6 +1165,8 @@ int CompilePrograms(const std::vector<std::string> &programs,
ProgramToModule(context, "source", program, output_log, &error));
if (error != 0)
return error;

StripBuiltinDefinitions(modules.back().get());
}
assert(modules.size() > 0 && modules.back() != nullptr);

Expand All @@ -1171,6 +1192,8 @@ int CompileProgram(const llvm::StringRef &input_filename,
return error;
}

StripBuiltinDefinitions(module.get());

return CompileModule(input_filename, module, output_buffer, output_log);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ llvm::cl::opt<bool> std430_ubo_layout(
llvm::cl::opt<bool> int8_support("int8", llvm::cl::init(true),
llvm::cl::desc("Allow 8-bit integers"));

// TODO(#1231): long vector support is required due to sqrt.
llvm::cl::opt<bool> long_vector_support(
"long-vector", llvm::cl::init(false),
"long-vector", llvm::cl::init(true),
llvm::cl::desc("Allow vectors of 8 and 16 elements. Experimental"));

llvm::cl::opt<bool> cl_arm_non_uniform_work_group_size(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: clspv %target %s -verify
// TODO(#1231)
// XFAIL: *
//
// Test that long-vector types are rejected when the support is not enabled.

Expand Down

0 comments on commit c0b1c96

Please sign in to comment.