Skip to content

Commit 2c155c2

Browse files
committed
Merge remote-tracking branch 'origin/sycl' into uwe/memops2d
2 parents c833442 + 67b1719 commit 2c155c2

File tree

45 files changed

+864
-484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+864
-484
lines changed

.github/workflows/sycl-nightly.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,23 @@ jobs:
201201
always()
202202
&& !cancelled()
203203
&& needs.build-win.outputs.build_conclusion == 'success'
204+
strategy:
205+
fail-fast: false
206+
matrix:
207+
include:
208+
- name: Intel L0 Gen12 GPU
209+
runner: '["Windows", "gen12"]'
210+
target_devices: level_zero:gpu
211+
212+
- name: Intel L0 Battlemage GPU
213+
runner: '["Windows", "bmg"]'
214+
target_devices: level_zero:gpu
215+
204216
uses: ./.github/workflows/sycl-windows-run-tests.yml
205217
with:
206-
name: Intel GEN12 Graphics with Level Zero
207-
runner: '["Windows","gen12"]'
208-
target_devices: level_zero:gpu
218+
name: ${{ matrix.name }}
219+
runner: ${{ matrix.runner }}
220+
target_devices: ${{ matrix.target_devices }}
209221
toolchain_artifact_filename: ${{ needs.build-win.outputs.toolchain_artifact_filename }}
210222

211223
cuda-aws-start:

clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,48 @@ class BinaryWrapper {
12931293
appendToGlobalDtors(M, Func, /*Priority*/ 1);
12941294
}
12951295

1296+
void createSyclRegisterWithAtexitUnregister(GlobalVariable *BinDesc) {
1297+
auto *UnregFuncTy =
1298+
FunctionType::get(Type::getVoidTy(C), /*isVarArg*/ false);
1299+
auto *UnregFunc =
1300+
Function::Create(UnregFuncTy, GlobalValue::InternalLinkage,
1301+
"sycl.descriptor_unreg.atexit", &M);
1302+
UnregFunc->setSection(".text.startup");
1303+
1304+
// Declaration for __sycl_unregister_lib(void*).
1305+
auto *UnregTargetTy =
1306+
FunctionType::get(Type::getVoidTy(C), getPtrTy(), /*isVarArg=*/false);
1307+
FunctionCallee UnregTargetC =
1308+
M.getOrInsertFunction("__sycl_unregister_lib", UnregTargetTy);
1309+
1310+
IRBuilder<> UnregBuilder(BasicBlock::Create(C, "entry", UnregFunc));
1311+
UnregBuilder.CreateCall(UnregTargetC, BinDesc);
1312+
UnregBuilder.CreateRetVoid();
1313+
1314+
auto *RegFuncTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg*/ false);
1315+
auto *RegFunc = Function::Create(RegFuncTy, GlobalValue::InternalLinkage,
1316+
"sycl.descriptor_reg", &M);
1317+
RegFunc->setSection(".text.startup");
1318+
1319+
auto *RegTargetTy =
1320+
FunctionType::get(Type::getVoidTy(C), getPtrTy(), false);
1321+
FunctionCallee RegTargetC =
1322+
M.getOrInsertFunction("__sycl_register_lib", RegTargetTy);
1323+
1324+
// `atexit` takes a `void(*)()` function pointer arg and returns an i32.
1325+
FunctionType *AtExitTy =
1326+
FunctionType::get(Type::getInt32Ty(C), getPtrTy(), false);
1327+
FunctionCallee AtExitC = M.getOrInsertFunction("atexit", AtExitTy);
1328+
1329+
IRBuilder<> RegBuilder(BasicBlock::Create(C, "entry", RegFunc));
1330+
RegBuilder.CreateCall(RegTargetC, BinDesc);
1331+
RegBuilder.CreateCall(AtExitC, UnregFunc);
1332+
RegBuilder.CreateRetVoid();
1333+
1334+
// Add this function to global destructors.
1335+
appendToGlobalCtors(M, RegFunc, /*Priority*/ 1);
1336+
}
1337+
12961338
public:
12971339
BinaryWrapper(StringRef Target, StringRef ToolName,
12981340
StringRef SymPropBCFiles = "")
@@ -1370,8 +1412,13 @@ class BinaryWrapper {
13701412

13711413
if (EmitRegFuncs) {
13721414
GlobalVariable *Desc = *DescOrErr;
1373-
createRegisterFunction(Kind, Desc);
1374-
createUnregisterFunction(Kind, Desc);
1415+
if (Kind == OffloadKind::SYCL &&
1416+
Triple(M.getTargetTriple()).isOSWindows()) {
1417+
createSyclRegisterWithAtexitUnregister(Desc);
1418+
} else {
1419+
createRegisterFunction(Kind, Desc);
1420+
createUnregisterFunction(Kind, Desc);
1421+
}
13751422
}
13761423
}
13771424
return &M;

devops/dependencies-igc-dev.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"linux": {
33
"igc_dev": {
4-
"github_tag": "igc-dev-788001e",
5-
"version": "788001e",
6-
"updated_at": "2025-09-03T22:42:39Z",
7-
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/3921755581/zip",
4+
"github_tag": "igc-dev-558c584",
5+
"version": "558c584",
6+
"updated_at": "2025-09-05T22:44:40Z",
7+
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/3941562792/zip",
88
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu"
99
}
1010
}

devops/scripts/benchmarks/html/scripts.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,12 @@ function fetchAndProcessData(url, isArchived = false) {
16061606
// Replace existing data for current data
16071607
loadedBenchmarkRuns = newRuns;
16081608
}
1609+
1610+
// The following variables have same values regardless of whether
1611+
// we load archived or current data
1612+
benchmarkMetadata = data.metadata || benchmarkMetadata || {};
1613+
benchmarkTags = data.tags || benchmarkTags || {};
1614+
16091615
initializeCharts();
16101616
})
16111617
.catch(error => {

llvm/lib/Frontend/Offloading/SYCLOffloadWrapper.cpp

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "llvm/Support/ErrorHandling.h"
3535
#include "llvm/Support/LineIterator.h"
3636
#include "llvm/Support/PropertySetIO.h"
37+
#include "llvm/TargetParser/Triple.h"
3738
#include "llvm/Transforms/Utils/ModuleUtils.h"
3839
#include <memory>
3940
#include <string>
@@ -734,6 +735,50 @@ struct Wrapper {
734735
// Add this function to global destructors.
735736
appendToGlobalDtors(M, Func, /*Priority*/ 1);
736737
}
738+
739+
void createSyclRegisterWithAtexitUnregister(GlobalVariable *FatbinDesc) {
740+
auto *UnregFuncTy =
741+
FunctionType::get(Type::getVoidTy(C), /*isVarArg*/ false);
742+
auto *UnregFunc =
743+
Function::Create(UnregFuncTy, GlobalValue::InternalLinkage,
744+
"sycl.descriptor_unreg.atexit", &M);
745+
UnregFunc->setSection(".text.startup");
746+
747+
// Declaration for __sycl_unregister_lib(void*).
748+
auto *UnregTargetTy =
749+
FunctionType::get(Type::getVoidTy(C), PointerType::getUnqual(C), false);
750+
FunctionCallee UnregTargetC =
751+
M.getOrInsertFunction("__sycl_unregister_lib", UnregTargetTy);
752+
753+
// Body of the unregister wrapper.
754+
IRBuilder<> UnregBuilder(BasicBlock::Create(C, "entry", UnregFunc));
755+
UnregBuilder.CreateCall(UnregTargetC, FatbinDesc);
756+
UnregBuilder.CreateRetVoid();
757+
758+
auto *RegFuncTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg*/ false);
759+
auto *RegFunc = Function::Create(RegFuncTy, GlobalValue::InternalLinkage,
760+
"sycl.descriptor_reg", &M);
761+
RegFunc->setSection(".text.startup");
762+
763+
auto *RegTargetTy =
764+
FunctionType::get(Type::getVoidTy(C), PointerType::getUnqual(C), false);
765+
FunctionCallee RegTargetC =
766+
M.getOrInsertFunction("__sycl_register_lib", RegTargetTy);
767+
768+
// `atexit` takes a `void(*)()` function pointer arg and returns an i32.
769+
FunctionType *AtExitTy = FunctionType::get(
770+
Type::getInt32Ty(C), PointerType::getUnqual(C), false);
771+
FunctionCallee AtExitC = M.getOrInsertFunction("atexit", AtExitTy);
772+
773+
IRBuilder<> RegBuilder(BasicBlock::Create(C, "entry", RegFunc));
774+
RegBuilder.CreateCall(RegTargetC, FatbinDesc);
775+
RegBuilder.CreateCall(AtExitC, UnregFunc);
776+
RegBuilder.CreateRetVoid();
777+
778+
// Finally, add to global constructors.
779+
appendToGlobalCtors(M, RegFunc, /*Priority*/ 1);
780+
}
781+
737782
}; // end of Wrapper
738783

739784
} // anonymous namespace
@@ -747,7 +792,11 @@ Error llvm::offloading::wrapSYCLBinaries(llvm::Module &M,
747792
return createStringError(inconvertibleErrorCode(),
748793
"No binary descriptors created.");
749794

750-
W.createRegisterFatbinFunction(Desc);
751-
W.createUnregisterFunction(Desc);
795+
if (Triple(M.getTargetTriple()).isOSWindows()) {
796+
W.createSyclRegisterWithAtexitUnregister(Desc);
797+
} else {
798+
W.createRegisterFatbinFunction(Desc);
799+
W.createUnregisterFunction(Desc);
800+
}
752801
return Error::success();
753802
}

sycl-jit/jit-compiler/CMakeLists.txt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ else()
99
set(SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT "/sycl-jit-toolchain/")
1010
endif()
1111

12-
# TODO: libdevice
13-
set(SYCL_JIT_RESOURCE_DEPS sycl-headers clang ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py)
12+
set(SYCL_JIT_RESOURCE_DEPS
13+
sycl-headers # include/sycl
14+
clang # lib/clang/N/include
15+
${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py)
1416

1517
if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
1618
# Somehow just "libclc" doesn't build "remangled-*" (and maybe whatever else).
17-
list(APPEND SYCL_JIT_RESOURCE_DEPS libclc libspirv-builtins)
19+
list(APPEND SYCL_JIT_RESOURCE_DEPS libclc libspirv-builtins) # lib/clc/*.bc
20+
endif()
21+
22+
if ("libdevice" IN_LIST LLVM_ENABLE_PROJECTS)
23+
list(APPEND SYCL_JIT_RESOURCE_DEPS libsycldevice) # lib/*.bc
1824
endif()
1925

2026
add_custom_command(
@@ -30,11 +36,14 @@ add_custom_command(
3036
if (WIN32)
3137
set(clang_exe ${CMAKE_BINARY_DIR}/bin/clang-cl.exe)
3238
set(SYCL_JIT_RESOURCE_CXX_FLAGS /O2 /std:c++17 /W0)
33-
if (CMAKE_BUILD_TYPE MATCHES "Debug")
34-
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /MDd)
35-
else()
36-
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /MD)
39+
40+
# Determine if we should use static (/MT) or dynamic (/MD) runtime
41+
set(USE_STATIC_RUNTIME 0)
42+
if(CMAKE_MSVC_RUNTIME_LIBRARY AND NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL")
43+
set(USE_STATIC_RUNTIME 1)
3744
endif()
45+
46+
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS /M$<IF:${USE_STATIC_RUNTIME},T,D>$<$<CONFIG:Debug>:d>)
3847
else()
3948
get_host_tool_path( clang CLANG clang_exe clang_target )
4049
set(SYCL_JIT_RESOURCE_CXX_FLAGS -O2 -Wno-c23-extensions -std=c++17 -fPIC -fvisibility=hidden)
@@ -50,7 +59,12 @@ endif()
5059
add_custom_command(
5160
OUTPUT ${SYCL_JIT_RESOURCE_OBJ}
5261
COMMAND
53-
${clang_exe} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS}
62+
# ${clang_exe}'s default target is not necessarily ${LLVM_HOST_TRIPLE}: when
63+
# cross compiling, it will be whatever the host tools were configured with,
64+
# and when building a cross compiler, it will be
65+
# ${LLVM_DEFAULT_TARGET_TRIPLE}. Rather than special casing these, just always
66+
# specify --target=${LLVM_HOST_TRIPLE}.
67+
${clang_exe} --target=${LLVM_HOST_TRIPLE} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS}
5468
DEPENDS
5569
${SYCL_JIT_RESOURCE_CPP}
5670
${CMAKE_CURRENT_SOURCE_DIR}/include/Resource.h

0 commit comments

Comments
 (0)