Skip to content

Commit 997edc4

Browse files
authored
[SYCLomatic] Remove the onedpl dependency in dnnl_utils.hpp (#2255)
Signed-off-by: Jiang, Zhiwei <[email protected]>
1 parent 2d0bda8 commit 997edc4

File tree

16 files changed

+82
-79
lines changed

16 files changed

+82
-79
lines changed

clang/lib/DPCT/AnalysisInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ void DpctFileInfo::insertHeader(HeaderType Type, unsigned Offset,
856856
// is added later
857857
case HT_DPL_Algorithm:
858858
case HT_DPL_Execution:
859-
case HT_DPCT_DNNL_Utils:
860859
concatHeader(OS, getHeaderSpelling(Type));
861860
return insertHeader(OS.str(), FirstIncludeOffset,
862861
InsertPosition::IP_AlwaysLeft);

clang/runtime/dpct-rt/include/dpct/dnnl_utils.hpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99
#ifndef __DPCT_DNNL_UTILS_HPP__
1010
#define __DPCT_DNNL_UTILS_HPP__
1111

12-
#include <oneapi/dpl/algorithm>
13-
#include <oneapi/dpl/execution>
14-
#include <oneapi/dpl/numeric>
15-
#include <oneapi/mkl.hpp>
16-
#include <oneapi/mkl/rng/device.hpp>
1712
#include <sycl/sycl.hpp>
13+
14+
#include <dpct/dpct.hpp>
15+
1816
#include <oneapi/dnnl/dnnl.hpp>
1917
#include <oneapi/dnnl/dnnl_sycl.hpp>
20-
#include <unordered_map>
18+
#include <oneapi/mkl.hpp>
19+
#include <oneapi/mkl/rng/device.hpp>
20+
2121
#include <algorithm>
2222
#include <list>
23+
#include <unordered_map>
2324

24-
#include "memory.hpp"
2525
#include "device.hpp"
2626
#include "lib_common_utils.hpp"
27+
#include "memory.hpp"
2728

2829
namespace dpct {
2930
namespace dnnl {
@@ -1023,20 +1024,21 @@ class engine_ext {
10231024
return q->fill<T>(static_cast<T *>(src), *static_cast<const T *>(value),
10241025
size_with_byte / sizeof(T));
10251026
}
1026-
template <typename T> struct no_zero_op {
1027-
T operator()(T e) {
1028-
if (!e) {
1029-
return 1;
1030-
}
1031-
return e;
1032-
}
1033-
};
10341027
template <typename T>
10351028
void transform_no_zero_with_type(sycl::queue *q, void *src, void *dst,
10361029
size_t num) {
1037-
std::transform(oneapi::dpl::execution::make_device_policy(*q),
1038-
static_cast<T *>(src), static_cast<T *>(src) + num,
1039-
static_cast<T *>(dst), no_zero_op<T>());
1030+
q->submit([&](sycl::handler &cgh) {
1031+
cgh.parallel_for<dpct_kernel_name<class zero_to_one, T>>(
1032+
sycl::range<1>(num), [=](sycl::id<1> idx) {
1033+
T *src_ptr = static_cast<T *>(src) + idx[0];
1034+
T *dst_ptr = static_cast<T *>(dst) + idx[0];
1035+
if (*src_ptr) {
1036+
*dst_ptr = *src_ptr;
1037+
} else {
1038+
*dst_ptr = 1;
1039+
}
1040+
});
1041+
});
10401042
}
10411043
void transform_no_zero(const memory_desc_ext &desc, void *src, void *dst);
10421044
::dnnl::memory::desc get_group_weight_desc(int group_count,

clang/test/dpct/dnn/activation.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: dpct -in-root %S -out-root %T/activation %S/activation.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/activation/activation.dp.cpp --match-full-lines %s
33

4-
// CHECK: #include <dpct/dnnl_utils.hpp>
54
// CHECK: #include <sycl/sycl.hpp>
6-
// CHECK: #include <dpct/dpct.hpp>
7-
// CHECK: #include <iostream>
8-
// CHECK: #include <vector>
5+
// CHECK-NEXT: #include <dpct/dpct.hpp>
6+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
7+
// CHECK-NEXT: #include <iostream>
8+
// CHECK-NEXT: #include <vector>
99
#include <cuda_runtime.h>
1010
#include <cudnn.h>
1111
#include <iostream>

clang/test/dpct/dnn/fill.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: dpct -in-root %S -out-root %T/fill %S/fill.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/fill/fill.dp.cpp --match-full-lines %s
33

4-
// CHECK: #include <dpct/dnnl_utils.hpp>
54
// CHECK: #include <sycl/sycl.hpp>
6-
// CHECK: #include <dpct/dpct.hpp>
7-
// CHECK: #include <iostream>
8-
// CHECK: #include <vector>
5+
// CHECK-NEXT: #include <dpct/dpct.hpp>
6+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
7+
// CHECK-NEXT: #include <iostream>
8+
// CHECK-NEXT: #include <vector>
99
#include <cuda_runtime.h>
1010
#include <cudnn.h>
1111
#include <iostream>

clang/test/dpct/dnn/lrn.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: dpct -in-root %S -out-root %T/lrn %S/lrn.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/lrn/lrn.dp.cpp --match-full-lines %s
33

4-
// CHECK: #include <dpct/dnnl_utils.hpp>
54
// CHECK: #include <sycl/sycl.hpp>
6-
// CHECK: #include <dpct/dpct.hpp>
7-
// CHECK: #include <iostream>
8-
// CHECK: #include <vector>
5+
// CHECK-NEXT: #include <dpct/dpct.hpp>
6+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
7+
// CHECK-NEXT: #include <iostream>
8+
// CHECK-NEXT: #include <vector>
99
#include <cuda_runtime.h>
1010
#include <cudnn.h>
1111
#include <iostream>

clang/test/dpct/dnn/memory.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// RUN: FileCheck --input-file %T/memory/memory.dp.cpp --match-full-lines %s
33
// RUN: %if build_lit %{icpx -c -fsycl %T/memory/memory.dp.cpp -o %T/memory/memory.dp.o %}
44

5-
// CHECK: #include <dpct/dnnl_utils.hpp>
65
// CHECK: #include <sycl/sycl.hpp>
7-
// CHECK: #include <dpct/dpct.hpp>
8-
// CHECK: #include <iostream>
9-
// CHECK: #include <vector>
6+
// CHECK-NEXT: #include <dpct/dpct.hpp>
7+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
8+
// CHECK-NEXT: #include <iostream>
9+
// CHECK-NEXT: #include <vector>
1010
#include <cuda_runtime.h>
1111
#include <cudnn.h>
1212
#include <iostream>

clang/test/dpct/dnn/pooling.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: dpct -in-root %S -out-root %T/pooling %S/pooling.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/pooling/pooling.dp.cpp --match-full-lines %s
33

4-
// CHECK: #include <dpct/dnnl_utils.hpp>
54
// CHECK: #include <sycl/sycl.hpp>
6-
// CHECK: #include <dpct/dpct.hpp>
7-
// CHECK: #include <iostream>
8-
// CHECK: #include <vector>
5+
// CHECK-NEXT: #include <dpct/dpct.hpp>
6+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
7+
// CHECK-NEXT: #include <iostream>
8+
// CHECK-NEXT: #include <vector>
99
#include <cuda_runtime.h>
1010
#include <cudnn.h>
1111
#include <iostream>

clang/test/dpct/dnn/reduction.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// RUN: FileCheck --input-file %T/reduction/reduction.dp.cpp --match-full-lines %s
33
// RUN: %if build_lit %{icpx -c -fsycl %T/reduction/reduction.dp.cpp -o %T/reduction/reduction.dp.o %}
44

5-
// CHECK: #include <dpct/dnnl_utils.hpp>
65
// CHECK: #include <sycl/sycl.hpp>
7-
// CHECK: #include <dpct/dpct.hpp>
8-
// CHECK: #include <iostream>
9-
// CHECK: #include <vector>
6+
// CHECK-NEXT: #include <dpct/dpct.hpp>
7+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
8+
// CHECK-NEXT: #include <iostream>
9+
// CHECK-NEXT: #include <vector>
1010
#include <cuda_runtime.h>
1111
#include <cudnn.h>
1212
#include <iostream>

clang/test/dpct/dnn/reorder.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: dpct -in-root %S -out-root %T/reorder %S/reorder.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
22
// RUN: FileCheck --input-file %T/reorder/reorder.dp.cpp --match-full-lines %s
33

4-
// CHECK: #include <dpct/dnnl_utils.hpp>
54
// CHECK: #include <sycl/sycl.hpp>
6-
// CHECK: #include <dpct/dpct.hpp>
7-
// CHECK: #include <iostream>
8-
// CHECK: #include <vector>
5+
// CHECK-NEXT: #include <dpct/dpct.hpp>
6+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
7+
// CHECK-NEXT: #include <iostream>
8+
// CHECK-NEXT: #include <vector>
99
#include <cuda_runtime.h>
1010
#include <cudnn.h>
1111
#include <iostream>

clang/test/dpct/dnn/rnn.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// RUN: dpct -in-root %S -out-root %T/rnn %S/rnn.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
44
// RUN: FileCheck --input-file %T/rnn/rnn.dp.cpp --match-full-lines %s
55

6-
// CHECK: #include <dpct/dnnl_utils.hpp>
76
// CHECK: #include <sycl/sycl.hpp>
8-
// CHECK: #include <dpct/dpct.hpp>
9-
// CHECK: #include <iostream>
10-
// CHECK: #include <vector>
7+
// CHECK-NEXT: #include <dpct/dpct.hpp>
8+
// CHECK-NEXT: #include <dpct/dnnl_utils.hpp>
9+
// CHECK-NEXT: #include <iostream>
10+
// CHECK-NEXT: #include <vector>
1111
#include <cuda_runtime.h>
1212
#include <cudnn.h>
1313
#include <iostream>

0 commit comments

Comments
 (0)