2019-01-30 12:47:28 +03:00
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Simeon Ehrig <s.ehrig@hzdr.de>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
2019-10-04 17:30:01 +03:00
# ifndef CLING_DEVICEKERNELINLINER_H
# define CLING_DEVICEKERNELINLINER_H
2019-01-30 12:47:28 +03:00
# include "ASTTransformer.h"
namespace cling
{
// This ASTTransformer adds an inline attribute to any CUDA __device__ kernel
// that does not have the attribute. Inlining solves a problem caused by
// incremental compilation of PTX code. In a normal compiler, all definitions
// of __global__ and __device__ kernels are in the same translation unit. In
// the incremental compiler, each kernel has its own translation unit. In case
// a __global__ kernel uses a __device__ function, this design caused an error.
// Instead of generating the PTX code of the __device__ kernel in the same file
// as the __global__ kernel, there is only an external declaration of the
2019-02-12 12:30:28 +03:00
// __device__ function. However, PTX does not support an external declaration of
// functions.
2019-01-30 12:47:28 +03:00
class DeviceKernelInliner : public ASTTransformer
{
public :
2019-10-04 17:30:01 +03:00
DeviceKernelInliner ( clang : : Sema * S ) ;
2019-01-30 12:47:28 +03:00
2019-10-04 17:30:01 +03:00
ASTTransformer : : Result Transform ( clang : : Decl * D ) override ;
2019-01-30 12:47:28 +03:00
} ;
}
2019-10-04 17:30:01 +03:00
# endif // CLING_DEVICEKERNELINLINER_H