Skip to content

Commit 035a63d

Browse files
sergey-semenovvladimirlaz
authored andcommitted
[SYCL] Remove the INLINE_IF_DEVICE workaround
Compilation flow has switched from linking SPIRV to linking LLVM bytecode. This workaround is no longer needed. Signed-off-by: Semenov, Sergey <[email protected]> Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent 1964034 commit 035a63d

File tree

6 files changed

+47
-62
lines changed

6 files changed

+47
-62
lines changed

sycl/include/CL/sycl/accessor.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class subscript_obj {
4343
subscript_obj(const accessor_t &acc, cl::sycl::id<accessorDim> &indexes)
4444
: accRef(acc), ids(indexes) {}
4545

46-
INLINE_IF_DEVICE subscript_obj<accessorDim, dataT, dimensions - 1, accessMode, accessTarget,
46+
subscript_obj<accessorDim, dataT, dimensions - 1, accessMode, accessTarget,
4747
isPlaceholder>
4848
operator[](size_t index) {
4949
ids[accessorDim - dimensions] = index;
@@ -66,7 +66,7 @@ class subscript_obj<accessorDim, dataT, 1, accessMode, accessTarget,
6666
subscript_obj(const accessor_t &acc, cl::sycl::id<accessorDim> &indexes)
6767
: accRef(acc), ids(indexes) {}
6868

69-
INLINE_IF_DEVICE dataT &operator[](size_t index) {
69+
dataT &operator[](size_t index) {
7070
ids[accessorDim - 1] = index;
7171
return accRef.__impl()->Data[getOffsetForId(
7272
accRef.__impl()->Range, ids, accRef.__impl()->Offset)];
@@ -87,7 +87,7 @@ class subscript_obj<accessorDim, dataT, 1, access::mode::read, accessTarget,
8787
subscript_obj(const accessor_t &acc, cl::sycl::id<accessorDim> &indexes)
8888
: accRef(acc), ids(indexes) {}
8989

90-
INLINE_IF_DEVICE typename detail::remove_AS<dataT>::type
90+
typename detail::remove_AS<dataT>::type
9191
operator[](size_t index) {
9292
ids[accessorDim - 1] = index;
9393
return accRef.__impl()->Data[getOffsetForId(
@@ -118,7 +118,7 @@ SYCL_ACCESSOR_IMPL(isTargetHostAccess(accessTarget) && dimensions == 0) {
118118
accessor_impl(dataT *Data) : Data(Data) {}
119119

120120
// Returns the number of accessed elements.
121-
INLINE_IF_DEVICE size_t get_count() const { return 1; }
121+
size_t get_count() const { return 1; }
122122
};
123123

124124
/// Implementation of host accessor.
@@ -133,7 +133,7 @@ SYCL_ACCESSOR_IMPL(isTargetHostAccess(accessTarget) && dimensions > 0) {
133133
: Data(Data), Range(Range), Offset(Offset) {}
134134

135135
// Returns the number of accessed elements.
136-
INLINE_IF_DEVICE size_t get_count() const { return Range.size(); }
136+
size_t get_count() const { return Range.size(); }
137137
};
138138

139139
/// Implementation of device (kernel) accessor providing access to a single
@@ -163,7 +163,7 @@ SYCL_ACCESSOR_IMPL(!isTargetHostAccess(accessTarget) &&
163163
{}
164164

165165
// Returns the number of accessed elements.
166-
INLINE_IF_DEVICE size_t get_count() const { return 1; }
166+
size_t get_count() const { return 1; }
167167

168168
static_assert(
169169
std::is_same<typename DeviceValueType<dataT, accessTarget>::type,
@@ -201,7 +201,7 @@ SYCL_ACCESSOR_IMPL(!isTargetHostAccess(accessTarget) &&
201201
{}
202202

203203
// Returns the number of accessed elements.
204-
INLINE_IF_DEVICE size_t get_count() const { return Range.size(); }
204+
size_t get_count() const { return Range.size(); }
205205

206206
static_assert(
207207
std::is_same<typename DeviceValueType<dataT, accessTarget>::type,
@@ -240,7 +240,7 @@ SYCL_ACCESSOR_IMPL(accessTarget == access::target::local &&
240240
}
241241

242242
// Returns the number of accessed elements.
243-
INLINE_IF_DEVICE size_t get_count() const { return 1; }
243+
size_t get_count() const { return 1; }
244244

245245
static_assert(
246246
std::is_same<typename DeviceValueType<dataT, accessTarget>::type,
@@ -285,7 +285,7 @@ SYCL_ACCESSOR_IMPL(accessTarget == access::target::local &&
285285
}
286286

287287
// Returns the number of accessed elements.
288-
INLINE_IF_DEVICE size_t get_count() const { return Range.size(); }
288+
size_t get_count() const { return Range.size(); }
289289

290290
static_assert(
291291
std::is_same<typename DeviceValueType<dataT, accessTarget>::type,
@@ -307,11 +307,11 @@ class accessor_base {
307307
using _ImplT =
308308
accessor_impl<dataT, dimensions, accessMode, accessTarget, isPlaceholder>;
309309

310-
INLINE_IF_DEVICE const _ImplT *__impl() const {
310+
const _ImplT *__impl() const {
311311
return reinterpret_cast<const _ImplT *>(this);
312312
}
313313

314-
INLINE_IF_DEVICE _ImplT *__impl() { return reinterpret_cast<_ImplT *>(this); }
314+
_ImplT *__impl() { return reinterpret_cast<_ImplT *>(this); }
315315

316316
static_assert(
317317
std::is_same<typename DeviceValueType<dataT, accessTarget>::type,
@@ -339,21 +339,21 @@ class accessor_base {
339339

340340
SYCL_ACCESSOR_SUBCLASS(accessor_common, accessor_base, true /* always */) {
341341
// Returns true if the current accessor is a placeholder accessor.
342-
INLINE_IF_DEVICE constexpr bool is_placeholder() const {
342+
constexpr bool is_placeholder() const {
343343
return isPlaceholder == access::placeholder::true_t;
344344
}
345345

346346
// Returns the size of the accessed memory in bytes.
347-
INLINE_IF_DEVICE size_t get_size() const { return this->get_count() * sizeof(dataT); }
347+
size_t get_size() const { return this->get_count() * sizeof(dataT); }
348348

349349
// Returns the number of accessed elements.
350-
INLINE_IF_DEVICE size_t get_count() const { return this->__impl()->get_count(); }
350+
size_t get_count() const { return this->__impl()->get_count(); }
351351

352-
template <int Dimensions = dimensions> INLINE_IF_DEVICE
352+
template <int Dimensions = dimensions>
353353
typename std::enable_if<(Dimensions > 0), range<Dimensions>>::type
354354
get_range() const { return this->__impl()->Range; }
355355

356-
template <int Dimensions = dimensions> INLINE_IF_DEVICE
356+
template <int Dimensions = dimensions>
357357
typename std::enable_if<(Dimensions > 0), id<Dimensions>>::type
358358
get_offset() const { return this->__impl()->Offset; }
359359
};
@@ -364,7 +364,7 @@ SYCL_ACCESSOR_SUBCLASS(accessor_opdata_w, accessor_common,
364364
accessMode == access::mode::discard_write ||
365365
accessMode == access::mode::discard_read_write) &&
366366
dimensions == 0) {
367-
INLINE_IF_DEVICE operator dataT &() const {
367+
operator dataT &() const {
368368
return this->__impl()->Data[0];
369369
}
370370
};
@@ -382,7 +382,7 @@ SYCL_ACCESSOR_SUBCLASS(accessor_subscript_wn, accessor_opdata_w,
382382

383383
subscript_obj<dimensions, dataT, dimensions - 1, accessMode, accessTarget,
384384
isPlaceholder>
385-
INLINE_IF_DEVICE operator[](size_t index) const {
385+
operator[](size_t index) const {
386386
id<dimensions> ids;
387387
ids[0] = index;
388388
return subscript_obj<dimensions, dataT, dimensions - 1, accessMode,
@@ -402,11 +402,11 @@ SYCL_ACCESSOR_SUBCLASS(accessor_subscript_w, accessor_subscript_wn,
402402
// classes. That's why operator[] defined in accessor_subscript_wn
403403
// is not visible here and we have to define
404404
// operator[](id<dimensions>) once again.
405-
INLINE_IF_DEVICE dataT &operator[](id<dimensions> index) const {
405+
dataT &operator[](id<dimensions> index) const {
406406
return this->operator[](
407407
getOffsetForId(this->get_range(), index, this->get_offset()));
408408
}
409-
INLINE_IF_DEVICE dataT &operator[](size_t index) const {
409+
dataT &operator[](size_t index) const {
410410
return this->__impl()->Data[index];
411411
}
412412
};
@@ -560,7 +560,7 @@ class accessor
560560
// implementation.
561561
_ImplT __impl;
562562

563-
INLINE_IF_DEVICE void __init(_ValueType *Ptr, range<dimensions> Range,
563+
void __init(_ValueType *Ptr, range<dimensions> Range,
564564
id<dimensions> Offset) {
565565
__impl.Data = Ptr;
566566
__impl.Range = Range;

sycl/include/CL/sycl/detail/array.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,67 +21,67 @@ namespace detail {
2121

2222
template <int dimensions = 1> class array {
2323
public:
24-
INLINE_IF_DEVICE array() : common_array{0} {}
24+
array() : common_array{0} {}
2525

2626
/* The following constructor is only available in the array struct
2727
* specialization where: dimensions==1 */
28-
template <int N = dimensions> INLINE_IF_DEVICE
28+
template <int N = dimensions>
2929
array(typename std::enable_if<(N == 1), size_t>::type dim0)
3030
: common_array{dim0} {}
3131

3232
/* The following constructor is only available in the array struct
3333
* specialization where: dimensions==2 */
34-
template <int N = dimensions> INLINE_IF_DEVICE
34+
template <int N = dimensions>
3535
array(typename std::enable_if<(N == 2), size_t>::type dim0, size_t dim1)
3636
: common_array{dim0, dim1} {}
3737

3838
/* The following constructor is only available in the array struct
3939
* specialization where: dimensions==3 */
40-
template <int N = dimensions> INLINE_IF_DEVICE
40+
template <int N = dimensions>
4141
array(typename std::enable_if<(N == 3), size_t>::type dim0, size_t dim1,
4242
size_t dim2)
4343
: common_array{dim0, dim1, dim2} {}
4444

4545
// Conversion operators to derived classes
46-
INLINE_IF_DEVICE operator cl::sycl::id<dimensions>() const {
46+
operator cl::sycl::id<dimensions>() const {
4747
cl::sycl::id<dimensions> result;
4848
for (int i = 0; i < dimensions; ++i) {
4949
result[i] = common_array[i];
5050
}
5151
return result;
5252
}
5353

54-
INLINE_IF_DEVICE operator cl::sycl::range<dimensions>() const {
54+
operator cl::sycl::range<dimensions>() const {
5555
cl::sycl::range<dimensions> result;
5656
for (int i = 0; i < dimensions; ++i) {
5757
result[i] = common_array[i];
5858
}
5959
return result;
6060
}
6161

62-
INLINE_IF_DEVICE size_t get(int dimension) const {
62+
size_t get(int dimension) const {
6363
check_dimension(dimension);
6464
return common_array[dimension];
6565
}
6666

67-
INLINE_IF_DEVICE size_t &operator[](int dimension) {
67+
size_t &operator[](int dimension) {
6868
check_dimension(dimension);
6969
return common_array[dimension];
7070
}
7171

72-
INLINE_IF_DEVICE size_t operator[](int dimension) const {
72+
size_t operator[](int dimension) const {
7373
check_dimension(dimension);
7474
return common_array[dimension];
7575
}
7676

77-
INLINE_IF_DEVICE array(const array<dimensions> &rhs) = default;
78-
INLINE_IF_DEVICE array(array<dimensions> &&rhs) = default;
79-
INLINE_IF_DEVICE array<dimensions> &operator=(const array<dimensions> &rhs) = default;
80-
INLINE_IF_DEVICE array<dimensions> &operator=(array<dimensions> &&rhs) = default;
77+
array(const array<dimensions> &rhs) = default;
78+
array(array<dimensions> &&rhs) = default;
79+
array<dimensions> &operator=(const array<dimensions> &rhs) = default;
80+
array<dimensions> &operator=(array<dimensions> &&rhs) = default;
8181

8282
// Returns true iff all elements in 'this' are equal to
8383
// the corresponding elements in 'rhs'.
84-
INLINE_IF_DEVICE bool operator==(const array<dimensions> &rhs) const {
84+
bool operator==(const array<dimensions> &rhs) const {
8585
for (int i = 0; i < dimensions; ++i) {
8686
if (this->common_array[i] != rhs.common_array[i]) {
8787
return false;
@@ -92,7 +92,7 @@ template <int dimensions = 1> class array {
9292

9393
// Returns true iff there is at least one element in 'this'
9494
// which is not equal to the corresponding element in 'rhs'.
95-
INLINE_IF_DEVICE bool operator!=(const array<dimensions> &rhs) const {
95+
bool operator!=(const array<dimensions> &rhs) const {
9696
for (int i = 0; i < dimensions; ++i) {
9797
if (this->common_array[i] != rhs.common_array[i]) {
9898
return true;

sycl/include/CL/sycl/detail/common.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ const char *stringifyErrorCode(cl_int error);
7474
#define ALWAYS_INLINE
7575
#endif
7676

77-
// TODO this macro is introduced to workaround SPIRV translator problem with
78-
// dropping linkonce_odr attribute leading to duplicated symbol errors in
79-
// the bitcode linker for functions defined in the headers. Remove once fixed.
80-
#ifdef __SYCL_DEVICE_ONLY__
81-
#define INLINE_IF_DEVICE ALWAYS_INLINE
82-
#else
83-
#define INLINE_IF_DEVICE
84-
#endif // __SYCL_DEVICE_ONLY__
85-
86-
8777
namespace cl {
8878
namespace sycl {
8979
namespace detail {

sycl/include/CL/sycl/handler.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ namespace detail {
6161
template <int Dim, class DstT> struct InitSizesST##POSTFIX; \
6262
\
6363
template <class DstT> struct InitSizesST##POSTFIX<1, DstT> { \
64-
static INLINE_IF_DEVICE void initSize(DstT &Dst) { \
64+
static void initSize(DstT &Dst) { \
6565
Dst[0] = cl::__spirv::get##POSTFIX<0>(); \
6666
} \
6767
}; \
6868
\
6969
template <class DstT> struct InitSizesST##POSTFIX<2, DstT> { \
70-
static INLINE_IF_DEVICE void initSize(DstT &Dst) { \
70+
static void initSize(DstT &Dst) { \
7171
Dst[1] = cl::__spirv::get##POSTFIX<1>(); \
7272
InitSizesST##POSTFIX<1, DstT>::initSize(Dst); \
7373
} \
7474
}; \
7575
\
7676
template <class DstT> struct InitSizesST##POSTFIX<3, DstT> { \
77-
static INLINE_IF_DEVICE void initSize(DstT &Dst) { \
77+
static void initSize(DstT &Dst) { \
7878
Dst[2] = cl::__spirv::get##POSTFIX<2>(); \
7979
InitSizesST##POSTFIX<2, DstT>::initSize(Dst); \
8080
} \

sycl/include/CL/sycl/id.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ template <int dimensions> class range;
1919
template <int dimensions = 1> struct id : public detail::array<dimensions> {
2020
public:
2121
using base = detail::array<dimensions>;
22-
INLINE_IF_DEVICE id() = default;
22+
id() = default;
2323

2424
/* The following constructor is only available in the id struct
2525
* specialization where: dimensions==1 */
@@ -149,7 +149,7 @@ template <int dimensions = 1> struct id : public detail::array<dimensions> {
149149
};
150150

151151
namespace detail {
152-
template <int dimensions> INLINE_IF_DEVICE
152+
template <int dimensions>
153153
size_t getOffsetForId(range<dimensions> Range, id<dimensions> Id,
154154
id<dimensions> Offset) {
155155
size_t offset = 0;

sycl/test/separate-compile/test.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
// >> ---- compile src1
22
// >> device compilation...
3-
// RUN: %clang -std=c++11 -fno-sycl-use-bitcode --sycl -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.spv
3+
// RUN: %clang -std=c++11 --sycl -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc
44
// >> host compilation...
55
// RUN: %clang -std=c++11 -include sycl_ihdr_a.h -g -c %s -o a.o
66
//
77
// >> ---- compile src2
88
// >> device compilation...
9-
// RUN: %clang -DB_CPP=1 -std=c++11 -fno-sycl-use-bitcode --sycl -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.spv
9+
// RUN: %clang -DB_CPP=1 -std=c++11 --sycl -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc
1010
// >> host compilation...
1111
// RUN: %clang -DB_CPP=1 -std=c++11 -include sycl_ihdr_b.h -g -c %s -o b.o
1212
//
1313
// >> ---- bundle .o with .spv
1414
// >> run bundler
15-
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -inputs=a.o,a_kernel.spv -outputs=a_fat.o
16-
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -inputs=b.o,b_kernel.spv -outputs=b_fat.o
15+
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -inputs=a.o,a_kernel.bc -outputs=a_fat.o
16+
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -inputs=b.o,b_kernel.bc -outputs=b_fat.o
1717
//
1818
// >> ---- unbundle fat objects
19-
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -outputs=a.o,a_kernel.spv -inputs=a_fat.o -unbundle
20-
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -outputs=b.o,b_kernel.spv -inputs=b_fat.o -unbundle
19+
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -outputs=a.o,a_kernel.bc -inputs=a_fat.o -unbundle
20+
// RUN: clang-offload-bundler -type=o -targets=host-x86_64,sycl-spir64-pc-linux-gnu -outputs=b.o,b_kernel.bc -inputs=b_fat.o -unbundle
2121
//
2222
// >> ---- link device code
23-
// >> convert to bitcode
24-
// RUN: llvm-spirv -r -o=a_kernel.bc a_kernel.spv
25-
// RUN: llvm-spirv -r -o=b_kernel.bc b_kernel.spv
26-
//
27-
// >> link bitcode
2823
// RUN: llvm-link -o=app.bc a_kernel.bc b_kernel.bc
2924
//
3025
// >> convert linked .bc to spirv

0 commit comments

Comments
 (0)