Skip to content

Commit 5ac0bf2

Browse files
committed
[SYCLomatic] Remove the insert replacement in the compiler defined location.
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent b2cf71f commit 5ac0bf2

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ void TypeInDeclRule::runRule(const MatchFinder::MatchResult &Result) {
854854
return;
855855
}
856856
if (const auto *TL = getNodeAsType<TypeLoc>(Result, "cudaTypeDef")) {
857+
auto CMD = dpct::DpctGlobalInfo::findAncestor<CXXMethodDecl>(TL);
858+
if (CMD && !CMD->isUserProvided())
859+
return;
857860
if (const auto *TypePtr = TL->getTypePtr()) {
858861
if (isTypeInAnalysisScope(TypePtr)) {
859862
if (const auto *const ET = dyn_cast<ElaboratedType>(TypePtr))

clang/test/dpct/replace-dim3.cu

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
#include <cstdio>
88
#include <algorithm>
9+
#include <queue>
10+
#include <thrust/complex.h>
911

12+
#include <cuda_runtime.h>
1013
#ifndef NO_BUILD_TEST
1114
#define NUM 23
1215
#define CALL_FUNC(func) func()
@@ -321,3 +324,42 @@ int dim3_implicit_ctor() {
321324
// CHECK: B b5 = {0, {1, {1}}};
322325
B b5 = {0, {1, {1}}};
323326
}
327+
328+
namespace test_dim3 {
329+
struct TuneParam {
330+
dim3 block = {1, 1, 1};
331+
332+
float time = 0;
333+
334+
TuneParam();
335+
TuneParam(const TuneParam &) = default;
336+
TuneParam(TuneParam &&) = default;
337+
// CHECK: TuneParam &operator=(const TuneParam &) = default;
338+
TuneParam &operator=(const TuneParam &) = default;
339+
// CHECK: TuneParam &operator=(TuneParam &&) = default;
340+
TuneParam &operator=(TuneParam &&) = default;
341+
};
342+
343+
struct TuneParamComp {
344+
bool operator()(const TuneParam &a, const TuneParam &b) const {
345+
return a.time < b.time;
346+
}
347+
};
348+
349+
class TuneCandidates : public std::priority_queue<TuneParam, std::vector<TuneParam>, TuneParamComp> {
350+
private:
351+
const size_t max_size = 5;
352+
float besttime = 0;
353+
354+
public:
355+
TuneCandidates(size_t size) : max_size(size) {}
356+
357+
void pushCandidate(TuneParam candidate) {
358+
if (size() < max_size) {
359+
push(candidate);
360+
return;
361+
}
362+
}
363+
};
364+
365+
} // namespace test_dim3

0 commit comments

Comments
 (0)