forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Structural improvements (LLVM kernel languages) #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kevinsala
merged 5 commits into
jdoerfert:llvm_kernel_languages
from
cad222:structural-improvements
Jun 16, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e8f1a6a
Delete broken install command
cadivus 66915bd
Create header file for `LanguageLunch.cpp`
cadivus 54fd430
Move `LanguageRuntime.cpp`
cadivus 1c0f430
Create header file for `LanguageRegistration.cpp`
cadivus 60c8312
Fix paths when installing `cuda_runtime.h` and `hip_runtime.h`
cadivus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //===------ LanguageLaunch.h - Header for LanguageLaunch.cpp ------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LANGUAGE_LAUNCH_H | ||
| #define LLVM_LANGUAGE_LAUNCH_H | ||
|
|
||
| #include "ExportedAPI.h" | ||
| #include "Types.h" | ||
| #include "OffloadAPI.h" | ||
|
|
||
| #include <cstdint> | ||
| #include <cstddef> | ||
| #include <algorithm> // for std::max | ||
|
|
||
| extern "C" { | ||
|
|
||
| struct LLVMOffloadKernelArgsTy { | ||
| size_t Size; | ||
| void *Args; | ||
| void *_; // Reserved for future use | ||
| }; | ||
|
|
||
| /// Push call configuration for kernel launch | ||
| unsigned llvmPushCallConfiguration(dim3 __grid_size, dim3 __block_size, | ||
| size_t __shared_memory, void *__stream); | ||
|
|
||
| /// Pop call configuration for kernel launch | ||
| unsigned llvmPopCallConfiguration(dim3 *__grid_size, dim3 *__block_size, | ||
| size_t *__shared_memory, void *__stream); | ||
|
|
||
| /// Internal kernel launch implementation | ||
| ol_result_t llvmLaunchKernelImpl(const char *KernelID, dim3 GridDim, | ||
| dim3 BlockDim, void *KernelArgsPtr, | ||
| size_t DynamicSharedMem, void *Stream, | ||
| LLVMOffloadKernelArgsTy *LOKA); | ||
|
|
||
| /// LLVM-style kernel launch entry points | ||
| unsigned __llvmLaunchKernel(const char *KernelID, dim3 GridDim, dim3 BlockDim, | ||
| void *KernelArgsPtr, size_t DynamicSharedMem, | ||
| void *Stream); | ||
|
|
||
| unsigned __llvmLaunchKernel_spt(const char *KernelID, dim3 GridDim, | ||
| dim3 BlockDim, void *KernelArgsPtr, | ||
| size_t DynamicSharedMem, void *Stream); | ||
|
|
||
| unsigned __llvmLaunchKernel_ptsz(const char *KernelID, dim3 GridDim, | ||
| dim3 BlockDim, void *KernelArgsPtr, | ||
| size_t DynamicSharedMem, void *Stream); | ||
|
|
||
| } | ||
|
|
||
| #endif // LLVM_LANGUAGE_LAUNCH_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| //===---- LanguageRegistration.h - Language (CUDA/HIP) registration api ---===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "ExportedAPI.h" | ||
|
|
||
| #include "OffloadAPI.h" | ||
|
|
||
| #include <cstdint> | ||
| #include <iterator> | ||
|
|
||
| #define HIP_FATBIN_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__" | ||
| constexpr auto HIP_FATBIN_MAGIC_STR_LEN = sizeof(HIP_FATBIN_MAGIC_STR) - 1; | ||
|
|
||
| namespace { | ||
| struct FatbinWrapperTy { | ||
| int Magic; | ||
| int Version; | ||
| const char *Data; | ||
| const char *DataEnd; | ||
| }; | ||
|
|
||
| template <typename T> T readAndAdvance(const char *&Ptr) { | ||
| auto V = *reinterpret_cast<const T *>(Ptr); | ||
| std::advance(Ptr, sizeof(T)); | ||
| return V; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| static void readTUFatbin(const char *Binary, const FatbinWrapperTy *FW); | ||
|
|
||
| static void readHIPFatbinEntries(const char *Binary, const char *HIPFatbinPtr); | ||
|
|
||
| /// Hidden, but exported, Registration API | ||
| ///{ | ||
| extern "C" { | ||
|
|
||
| void llvmRegisterFunction(const char *Binary, const char *KernelID, | ||
| char *KernelName, const char *KernelName1, int, | ||
| uint3 *, uint3 *, dim3 *, dim3 *, int *); | ||
|
|
||
| const char *llvmRegisterFatBinary(const char *Binary); | ||
|
|
||
| void llvmUnregisterFatBinary(void *Handle); | ||
|
|
||
| void llvmRegisterVar(void **, char *, char *, const char *, int, int, int, | ||
| int); | ||
|
|
||
| void llvmRegisterManagedVar(void **, char *, char *, const char *, size_t, | ||
| unsigned); | ||
|
|
||
| void llvmRegisterSurface(void **, const struct surfaceReference *, | ||
| const void **, const char *, int, int); | ||
|
|
||
| void llvmRegisterTexture(void **, const struct textureReference *, | ||
| const void **, const char *, int, int, int); | ||
|
|
||
| } | ||
| ///} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.