mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
CUDA and HIP offloading currently assumes that the source language also implies the device backend: CUDA maps to NVPTX/CUDA and HIP maps to AMDGPU/HSA. That is too restrictive for the LLVM offload path, where the language frontend and the device backend can be separate choices. Using `-foffload-via-llvm` we can split the kernel language from backend assumptions. When enabled, the driver suppresses the vendor runtime/header paths, injects the LLVM-provided generic GPU device headers and language runtime headers, and links the LLVM CUDA/HIP runtime libraries from #211694 instead. It also provides tests for #211694 since they require the frontend to run. Assisted by GPT-5.5, checked and reviewed manually Co-authored-by: Johannes Doerfert <jdoerfert.llvm@gmail.com> Co-authored-by: Jonas Greifenhain <cadivus@daverkomp.de>
68 lines
3 KiB
C++
68 lines
3 KiB
C++
//===-- LanguageAliases.inc - Language runtime symbol aliases -------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM offload kernel runtime implements the shared __llvm* entry points
|
|
// once. These wrappers expose the CUDA/HIP ABI names, such as
|
|
// __cudaRegisterFunction and __hipPopCallConfiguration, as forwarding entry
|
|
// points to the shared implementations.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// This file intentionally has no include guard. It is included once for each
|
|
// LANGUAGE value to emit each language's alias definitions.
|
|
|
|
#ifndef LANGUAGE
|
|
#error This file should be included, or used, with a LANGUAGE macro set.
|
|
#endif
|
|
|
|
#define LA_IMPL2(PREFIX, L, NAME) PREFIX##L##NAME
|
|
#define LA_IMPL1(PREFIX, L, NAME) LA_IMPL2(PREFIX, L, NAME)
|
|
#define LANGUAGE_NAME(PREFIX, NAME) LA_IMPL1(PREFIX, LANGUAGE, NAME)
|
|
|
|
extern "C" void
|
|
LANGUAGE_NAME(__, RegisterFunction)(const char *Binary, const char *KernelID,
|
|
char *KernelName, const char *KernelName1,
|
|
int ThreadLimit, uint3 *Tid, uint3 *Bid,
|
|
dim3 *BlockDim, dim3 *GridDim, int *WSize) {
|
|
__llvmRegisterFunction(Binary, KernelID, KernelName, KernelName1, ThreadLimit,
|
|
Tid, Bid, BlockDim, GridDim, WSize);
|
|
}
|
|
|
|
extern "C" void LANGUAGE_NAME(__, RegisterVar)(void **Data, char *HostVar,
|
|
char *DeviceAddress,
|
|
const char *DeviceName, int Ext,
|
|
int Size, int Constant,
|
|
int Global) {
|
|
__llvmRegisterVar(Data, HostVar, DeviceAddress, DeviceName, Ext, Size,
|
|
Constant, Global);
|
|
}
|
|
|
|
extern "C" void LANGUAGE_NAME(__,
|
|
RegisterManagedVar)(void **Data, char *HostVar,
|
|
char *DeviceAddress,
|
|
const char *DeviceName,
|
|
size_t Size, unsigned Align) {
|
|
__llvmRegisterManagedVar(Data, HostVar, DeviceAddress, DeviceName, Size,
|
|
Align);
|
|
}
|
|
|
|
extern "C" void LANGUAGE_NAME(__, RegisterSurface)(
|
|
void **Data, const struct surfaceReference *SurfRef, const void **DevPtr,
|
|
const char *Name, int Dim, int Ext) {
|
|
__llvmRegisterSurface(Data, SurfRef, DevPtr, Name, Dim, Ext);
|
|
}
|
|
|
|
extern "C" void LANGUAGE_NAME(__, RegisterTexture)(
|
|
void **Data, const struct textureReference *TexRef, const void **DevPtr,
|
|
const char *Name, int Dim, int Norm, int Ext) {
|
|
__llvmRegisterTexture(Data, TexRef, DevPtr, Name, Dim, Norm, Ext);
|
|
}
|
|
|
|
#undef LANGUAGE_NAME
|
|
#undef LA_IMPL1
|
|
#undef LA_IMPL2
|