1 | //===----------- DeviceOffload.h - Device Offloading ------------*- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file implements classes required for offloading to CUDA devices. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H |
14 | #define LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H |
15 | |
16 | #include "IncrementalParser.h" |
17 | #include "llvm/Support/FileSystem.h" |
18 | #include "llvm/Support/VirtualFileSystem.h" |
19 | |
20 | namespace clang { |
21 | |
22 | class IncrementalCUDADeviceParser : public IncrementalParser { |
23 | public: |
24 | IncrementalCUDADeviceParser( |
25 | Interpreter &Interp, std::unique_ptr<CompilerInstance> Instance, |
26 | IncrementalParser &HostParser, llvm::LLVMContext &LLVMCtx, |
27 | llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS, |
28 | llvm::Error &Err); |
29 | |
30 | llvm::Expected<PartialTranslationUnit &> |
31 | Parse(llvm::StringRef Input) override; |
32 | |
33 | // Generate PTX for the last PTU |
34 | llvm::Expected<llvm::StringRef> GeneratePTX(); |
35 | |
36 | // Generate fatbinary contents in memory |
37 | llvm::Error GenerateFatbinary(); |
38 | |
39 | ~IncrementalCUDADeviceParser(); |
40 | |
41 | protected: |
42 | IncrementalParser &HostParser; |
43 | int SMVersion; |
44 | llvm::SmallString<1024> PTXCode; |
45 | llvm::SmallVector<char, 1024> FatbinContent; |
46 | llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS; |
47 | }; |
48 | |
49 | } // namespace clang |
50 | |
51 | #endif // LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H |
52 |