1 //===----------- DeviceOffload.h - Device Offloading ------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements classes required for offloading to CUDA devices.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H
14 #define LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H
16 #include "IncrementalParser.h"
17 #include "llvm/Support/FileSystem.h"
18 #include "llvm/Support/VirtualFileSystem.h"
22 class IncrementalCUDADeviceParser
: public IncrementalParser
{
24 IncrementalCUDADeviceParser(
25 Interpreter
&Interp
, std::unique_ptr
<CompilerInstance
> Instance
,
26 IncrementalParser
&HostParser
, llvm::LLVMContext
&LLVMCtx
,
27 llvm::IntrusiveRefCntPtr
<llvm::vfs::InMemoryFileSystem
> VFS
,
30 llvm::Expected
<PartialTranslationUnit
&>
31 Parse(llvm::StringRef Input
) override
;
33 // Generate PTX for the last PTU
34 llvm::Expected
<llvm::StringRef
> GeneratePTX();
36 // Generate fatbinary contents in memory
37 llvm::Error
GenerateFatbinary();
39 ~IncrementalCUDADeviceParser();
42 IncrementalParser
&HostParser
;
44 llvm::SmallString
<1024> PTXCode
;
45 llvm::SmallVector
<char, 1024> FatbinContent
;
46 llvm::IntrusiveRefCntPtr
<llvm::vfs::InMemoryFileSystem
> VFS
;
51 #endif // LLVM_CLANG_LIB_INTERPRETER_DEVICE_OFFLOAD_H