Skip to content
Draft
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
15 changes: 6 additions & 9 deletions clang/test/Driver/sycl-linker-wrapper-image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,18 @@ int main() {
// CHECK-DAG: @.sycl_offloading.target.0 = internal unnamed_addr constant [7 x i8] c"spir64\00"
// CHECK-DAG: @.sycl_offloading.opts.compile.0 = internal unnamed_addr constant [1 x i8] zeroinitializer
// CHECK-DAG: @.sycl_offloading.opts.link.0 = internal unnamed_addr constant [1 x i8] zeroinitializer
// CHECK-DAG: @prop = internal unnamed_addr constant [17 x i8] c"DeviceLibReqMask\00"
// CHECK-DAG: @__sycl_offload_prop_sets_arr = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop, ptr null, i32 1, i64 0 }]
// CHECK-DAG: @SYCL_PropSetName = internal unnamed_addr constant [24 x i8] c"SYCL/devicelib req mask\00"
// CHECK-DAG: @prop.1 = internal unnamed_addr constant [8 x i8] c"aspects\00"
// CHECK-DAG: @prop = internal unnamed_addr constant [8 x i8] c"aspects\00"
// CHECK-DAG: @prop_val = internal unnamed_addr constant [8 x i8] zeroinitializer
// CHECK-DAG: @__sycl_offload_prop_sets_arr.2 = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop.1, ptr @prop_val, i32 2, i64 8 }]
// CHECK-DAG: @SYCL_PropSetName.3 = internal unnamed_addr constant [25 x i8] c"SYCL/device requirements\00"
// CHECK-DAG: @SYCL_PropSetName.4 = internal unnamed_addr constant [22 x i8] c"SYCL/kernel param opt\00"
// CHECK-DAG: @__sycl_offload_prop_sets_arr.5 = internal constant [3 x %_pi_device_binary_property_set_struct] [%_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName, ptr @__sycl_offload_prop_sets_arr, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.3, ptr @__sycl_offload_prop_sets_arr.2, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr.2, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.4, ptr null, ptr null }]
// CHECK-DAG: @__sycl_offload_prop_sets_arr = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop, ptr @prop_val, i32 2, i64 8 }]
// CHECK-DAG: @SYCL_PropSetName = internal unnamed_addr constant [25 x i8] c"SYCL/device requirements\00"
// CHECK-DAG: @SYCL_PropSetName.1 = internal unnamed_addr constant [22 x i8] c"SYCL/kernel param opt\00"
// CHECK-DAG: @__sycl_offload_prop_sets_arr.2 = internal constant [2 x %_pi_device_binary_property_set_struct] [%_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName, ptr @__sycl_offload_prop_sets_arr, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.1, ptr null, ptr null }]
// CHECK-DAG: @.sycl_offloading.0.data = internal unnamed_addr constant [912 x i8]
// CHECK-DAG: @__sycl_offload_entry_name = internal unnamed_addr constant [25 x i8] c"_ZTSZ4mainE11fake_kernel\00"
// CHECK-DAG: @__sycl_offload_entries_arr = internal constant [1 x %struct.__tgt_offload_entry] [%struct.__tgt_offload_entry { i64 0, i16 1, i16 8, i32 0, ptr null, ptr @__sycl_offload_entry_name, i64 0, i64 0, ptr null }]
// CHECK-DAG: @.sycl_offloading.0.info = internal local_unnamed_addr constant [2 x i64] [i64 ptrtoint (ptr @.sycl_offloading.0.data to i64), i64 912], section ".tgtimg", align 16
// CHECK-DAG: @llvm.used = appending global [1 x ptr] [ptr @.sycl_offloading.0.info], section "llvm.metadata"
// CHECK-DAG: @.sycl_offloading.device_images = internal unnamed_addr constant [1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 3, i8 4, i8 0, ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr @.sycl_offloading.opts.link.0, ptr @.sycl_offloading.0.data, ptr getelementptr ([912 x i8], ptr @.sycl_offloading.0.data, i64 0, i64 912), ptr @__sycl_offload_entries_arr, ptr getelementptr ([1 x %struct.__tgt_offload_entry], ptr @__sycl_offload_entries_arr, i64 0, i64 1), ptr @__sycl_offload_prop_sets_arr.5, ptr getelementptr ([3 x %_pi_device_binary_property_set_struct], ptr @__sycl_offload_prop_sets_arr.5, i64 0, i64 3) }]
// CHECK-DAG: @.sycl_offloading.device_images = internal unnamed_addr constant [1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 3, i8 4, i8 0, ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr @.sycl_offloading.opts.link.0, ptr @.sycl_offloading.0.data, ptr getelementptr ([912 x i8], ptr @.sycl_offloading.0.data, i64 0, i64 912), ptr @__sycl_offload_entries_arr, ptr getelementptr ([1 x %struct.__tgt_offload_entry], ptr @__sycl_offload_entries_arr, i64 0, i64 1), ptr @__sycl_offload_prop_sets_arr.2, ptr getelementptr ([2 x %_pi_device_binary_property_set_struct], ptr @__sycl_offload_prop_sets_arr.2, i64 0, i64 2) }]
// CHECK-DAG: @.sycl_offloading.descriptor = internal constant %__sycl.tgt_bin_desc { i16 1, i16 1, ptr @.sycl_offloading.device_images, ptr null, ptr null }
// CHECK-DAG: @llvm.global_ctors = {{.*}} { i32 1, ptr @sycl.descriptor_reg, ptr null }]
// CHECK-DAG: @llvm.global_dtors = {{.*}} { i32 1, ptr @sycl.descriptor_unreg, ptr null }]
Expand Down
16 changes: 16 additions & 0 deletions llvm/include/llvm/SYCLLowerIR/SYCLDeviceLibBF16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===----- SYCLDeviceLibBF16.h - get SYCL devicelib required Info -----=-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

namespace llvm {
class Function;
class Module;
bool isSYCLDeviceLibBF16Used(const Module &M);
bool isBF16DeviceLibFuncDecl(const Function &F);
} // namespace llvm
47 changes: 0 additions & 47 deletions llvm/include/llvm/SYCLLowerIR/SYCLDeviceLibReqMask.h

This file was deleted.

1 change: 0 additions & 1 deletion llvm/include/llvm/SYCLPostLink/ComputeModuleRuntimeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#pragma once

#include "llvm/ADT/SetVector.h"
#include "llvm/SYCLLowerIR/SYCLDeviceLibReqMask.h"
#include "llvm/Support/PropertySetIO.h"
#include <string>
namespace llvm {
Expand Down
3 changes: 0 additions & 3 deletions llvm/include/llvm/Support/PropertySetIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ class PropertySetRegistry {
"SYCL/specialization constants";
static constexpr char SYCL_SPEC_CONSTANTS_DEFAULT_VALUES[] =
"SYCL/specialization constants default values";
// TODO: remove SYCL_DEVICELIB_REQ_MASK when devicelib online linking path
// is totally removed.
static constexpr char SYCL_DEVICELIB_REQ_MASK[] = "SYCL/devicelib req mask";
static constexpr char SYCL_DEVICELIB_METADATA[] = "SYCL/devicelib metadata";
static constexpr char SYCL_KERNEL_PARAM_OPT_INFO[] = "SYCL/kernel param opt";
static constexpr char SYCL_PROGRAM_METADATA[] = "SYCL/program metadata";
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/SYCLLowerIR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_llvm_component_library(LLVMSYCLLowerIR
SYCLAddOptLevelAttribute.cpp
SYCLConditionalCallOnDevice.cpp
SYCLCreateNVVMAnnotations.cpp
SYCLDeviceLibReqMask.cpp
SYCLDeviceLibBF16.cpp
SYCLDeviceRequirements.cpp
SYCLKernelParamOptInfo.cpp
SYCLJointMatrixTransform.cpp
Expand Down
61 changes: 61 additions & 0 deletions llvm/lib/SYCLLowerIR/SYCLDeviceLibBF16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//==----- SYCLDeviceLibBF16.cpp - get SYCL BF16 devicelib required Info ----==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This file provides some utils to analyze whether user's device image does
// depend on sycl bfloat16 device library functions.
//===----------------------------------------------------------------------===//

#include "llvm/SYCLLowerIR/SYCLDeviceLibBF16.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/TargetParser/Triple.h"

static constexpr char DEVICELIB_FUNC_PREFIX[] = "__devicelib_";

using namespace llvm;

static llvm::SmallVector<StringRef, 14> BF16DeviceLibFuncs = {
"__devicelib_ConvertFToBF16INTEL",
"__devicelib_ConvertBF16ToFINTEL",
"__devicelib_ConvertFToBF16INTELVec1",
"__devicelib_ConvertBF16ToFINTELVec1",
"__devicelib_ConvertFToBF16INTELVec2",
"__devicelib_ConvertBF16ToFINTELVec2",
"__devicelib_ConvertFToBF16INTELVec3",
"__devicelib_ConvertBF16ToFINTELVec3",
"__devicelib_ConvertFToBF16INTELVec4",
"__devicelib_ConvertBF16ToFINTELVec4",
"__devicelib_ConvertFToBF16INTELVec8",
"__devicelib_ConvertBF16ToFINTELVec8",
"__devicelib_ConvertFToBF16INTELVec16",
"__devicelib_ConvertBF16ToFINTELVec16",
};

bool llvm::isSYCLDeviceLibBF16Used(const Module &M) {
if (!Triple(M.getTargetTriple()).isSPIROrSPIRV())
return false;

for (auto Fn : BF16DeviceLibFuncs) {
Function *BF16Func = M.getFunction(Fn);
if (BF16Func && BF16Func->isDeclaration())
return true;
}

return false;
}

bool llvm::isBF16DeviceLibFuncDecl(const Function &F) {
if (!F.isDeclaration() || !F.getName().starts_with(DEVICELIB_FUNC_PREFIX))
return false;
for (auto BFunc : BF16DeviceLibFuncs) {
if (!F.getName().compare(BFunc))
return true;
}

return false;
}
Loading