Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ class SYCLIntegrationHeader {
/// Whether this kernel is an ESIMD one.
bool IsESIMDKernel;

/// Kernel source file name.
std::string FileName;

/// Kernel location function name.
std::string FunctionName;

/// Kernel location - line number.
unsigned LineNumber;

/// Kernel location - column number.
unsigned ColumnNumber;

/// Descriptor of kernel actual parameters.
SmallVector<KernelParamDesc, 8> Params;

Expand All @@ -405,7 +417,9 @@ class SYCLIntegrationHeader {
KernelDesc(const FunctionDecl *SyclKernel, QualType NameType,
SourceLocation KernelLoc, bool IsESIMD, bool IsUnnamedKernel)
: SyclKernel(SyclKernel), NameType(NameType), KernelLocation(KernelLoc),
IsESIMDKernel(IsESIMD), IsUnnamedKernel(IsUnnamedKernel) {}
IsESIMDKernel(IsESIMD), IsUnnamedKernel(IsUnnamedKernel),// {}
LineNumber(KernelLocation.getPresumedLoc().getLine()), //getLineNumber()),
ColumnNumber(KernelLocation.getPresumedLoc().getColumn()) {} //ColumnNumber()) {}

void updateKernelNames(StringRef Name, StringRef StableName) {
this->Name = Name.str();
Expand Down
12 changes: 12 additions & 0 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4707,6 +4707,18 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
O << " __SYCL_DLL_LOCAL\n";
O << " static constexpr bool isESIMD() { return " << K.IsESIMDKernel
<< "; }\n";
O << " __SYCL_DLL_LOCAL\n";
O << " static constexpr const char* getFileName() { return " << K.FileName
<< "\"; }\n";
O << " __SYCL_DLL_LOCAL\n";
O << " static constexpr const char* getFunctionName() { return "
<< K.FunctionName << "\"; }\n";
O << " __SYCL_DLL_LOCAL\n";
O << " static constexpr unsigned getLineNumber() { return " << K.LineNumber
<< "\"; }\n";
O << " __SYCL_DLL_LOCAL\n";
O << " static constexpr unsigned getColumnNumber() { return "
<< K.ColumnNumber << "\"; }\n";
O << "};\n";
CurStart += N;
}
Expand Down
2 changes: 2 additions & 0 deletions clang/test/CodeGenSYCL/int_header1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,7 @@ int main() {
KernelInfo<class nm1::KernelName8<nm1::nm2::C>>::getName();
KernelInfo<class TmplClassInAnonNS<class ClassInAnonNS>>::getName();
KernelInfo<class nm1::KernelName9<char>>::getName();
// KernelInfo<class KernelName>::codeLocation();
// add code location KernelInfo methods
#endif //__SYCL_DEVICE_ONLY__
}
21 changes: 21 additions & 0 deletions sycl/include/CL/sycl/detail/kernel_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ template <auto &SpecName> const char *get_spec_constant_symbolic_ID_impl();
template <auto &SpecName> const char *get_spec_constant_symbolic_ID();
#endif

//template<typename CodeLocation> const detail::ContextImplPtr *detail::code_location();
// { return ""; }
#ifndef __SYCL_UNNAMED_LAMBDA__
template <class KernelNameType> struct KernelInfo {
static constexpr unsigned getNumParams() { return 0; }
Expand All @@ -75,6 +77,13 @@ template <class KernelNameType> struct KernelInfo {
}
static constexpr const char *getName() { return ""; }
static constexpr bool isESIMD() { return 0; }
#ifndef DNDEBUG
static constexpr const char *getFileName() { return ""; }
static constexpr const char *getFunctionName() { return ""; }
static constexpr unsigned getLineNumber() { return 0; }
static constexpr unsigned getColumnNumber() { return 0; }
#endif
Comment thread
schittir marked this conversation as resolved.
Outdated

};
#else
template <char...> struct KernelInfoData {
Expand All @@ -85,6 +94,12 @@ template <char...> struct KernelInfoData {
}
static constexpr const char *getName() { return ""; }
static constexpr bool isESIMD() { return 0; }
#ifndef DNDEBUG
static constexpr const char *getFileName() { return ""; }
static constexpr const char *getFunctionName() { return ""; }
static constexpr unsigned getLineNumber() { return 0; }
static constexpr unsigned getColumnNumber() { return 0; }
#endif
};

// C++14 like index_sequence and make_index_sequence
Expand Down Expand Up @@ -123,6 +138,12 @@ template <class KernelNameType> struct KernelInfo {
}
static constexpr const char *getName() { return SubKernelInfo::getName(); }
static constexpr bool isESIMD() { return SubKernelInfo::isESIMD(); }
#ifndef DNDEBUG
static constexpr const char *getFileName() { return ""; }
static constexpr const char *getFunctionName() { return ""; }
static constexpr unsigned getLineNumber() { return 0; }
static constexpr unsigned getColumnNumber() { return 0; }
#endif
};
#endif //__SYCL_UNNAMED_LAMBDA__

Expand Down