Skip to content

Commit 791c3b6

Browse files
authored
[SYCLomatic] Enable migration of cudnnGetVersion (#771)
Signed-off-by: Wang, Hao3 <[email protected]>
1 parent 9707f0e commit 791c3b6

File tree

7 files changed

+55
-2
lines changed

7 files changed

+55
-2
lines changed

clang/lib/DPCT/APINamesCUDNN.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
//===-----------------------------------------------------------------===//
88

99
// Base API
10+
FEATURE_REQUEST_FACTORY(HelperFeatureEnum::DnnlUtils_get_version,
11+
CALL_FACTORY_ENTRY("cudnnGetVersion",
12+
CALL(MapNames::getDpctNamespace() +
13+
"dnnl::get_version")))
14+
1015
FEATURE_REQUEST_FACTORY(HelperFeatureEnum::DnnlUtils_engine_ext,
1116
ASSIGNABLE_FACTORY(MEMBER_CALL_FACTORY_ENTRY(
1217
"cudnnCreate", DEREF(ARG_WC(0)), false,

clang/lib/DPCT/APINames_cuDNN.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ENTRY(cudnnGetTensor4dDescriptor, cudnnGetTensor4dDescriptor, true, NO_FLAG, P4,
9494
ENTRY(cudnnGetTensorNdDescriptor, cudnnGetTensorNdDescriptor, true, NO_FLAG, P4, "Successful")
9595
ENTRY(cudnnGetTensorSizeInBytes, cudnnGetTensorSizeInBytes, true, NO_FLAG, P4, "Successful")
9696
ENTRY(cudnnGetTensorTransformDescriptor, cudnnGetTensorTransformDescriptor, false, NO_FLAG, P4, "comment")
97-
ENTRY(cudnnGetVersion, cudnnGetVersion, false, NO_FLAG, P4, "comment")
97+
ENTRY(cudnnGetVersion, cudnnGetVersion, true, NO_FLAG, P4, "comment")
9898
ENTRY(cudnnInitTransformDest, cudnnInitTransformDest, false, NO_FLAG, P4, "comment")
9999
ENTRY(cudnnLRNCrossChannelForward, cudnnLRNCrossChannelForward, true, NO_FLAG, P4, "Successful")
100100
ENTRY(cudnnNormalizationForwardInference, cudnnNormalizationForwardInference, true, NO_FLAG, P4, "comment")

clang/lib/DPCT/DNNAPIMigration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void CuDNNAPIRule::registerMatcher(ast_matchers::MatchFinder &MF) {
179179
"cudnnCreateDropoutDescriptor", "cudnnSetDropoutDescriptor",
180180
"cudnnGetDropoutDescriptor", "cudnnDropoutGetReserveSpaceSize",
181181
"cudnnRestoreDropoutDescriptor", "cudnnDropoutForward", "cudnnDropoutBackward",
182-
"cudnnDestroyDropoutDescriptor");
182+
"cudnnDestroyDropoutDescriptor", "cudnnGetVersion");
183183
};
184184

185185
MF.addMatcher(

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838

3939
namespace dpct {
4040
namespace dnnl {
41+
// DPCT_LABEL_BEGIN|get_version|dpct::dnnl
42+
// DPCT_DEPENDENCY_EMPTY
43+
// DPCT_CODE
44+
/// Get concatenated library version as an integer.
45+
static inline size_t get_version() {
46+
const ::dnnl::version_t *ver = ::dnnl::version();
47+
return ver->major * 1000 + ver->minor * 100 + ver->patch;
48+
}
49+
// DPCT_LABEL_END
4150
class engine_ext;
4251
typedef oneapi::mkl::rng::philox4x32x10 rng_engine_t;
4352
// DPCT_LABEL_BEGIN|memory_format_tag|dpct::dnnl

clang/test/dpct/dnn/version.cu

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: dpct -in-root %S -out-root %T/version %S/version.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
2+
// RUN: FileCheck --input-file %T/version/version.dp.cpp --match-full-lines %s
3+
#include <cuda_runtime.h>
4+
#include <cudnn.h>
5+
#include <iostream>
6+
#include <vector>
7+
8+
9+
int main() {
10+
// CHECK: size_t version = dpct::dnnl::get_version();
11+
size_t version = cudnnGetVersion();
12+
13+
return 0;
14+
}

clang/test/dpct/helper_files_ref/include/dnnl_utils.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
namespace dpct {
2828
namespace dnnl {
29+
/// Get concatenated library version as an integer.
30+
static inline size_t get_version() {
31+
const ::dnnl::version_t *ver = ::dnnl::version();
32+
return ver->major * 1000 + ver->minor * 100 + ver->patch;
33+
}
2934
class engine_ext;
3035
typedef oneapi::mkl::rng::philox4x32x10 rng_engine_t;
3136
/// An enum class representing memory layout. Used by
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: dpct --format-range=none --use-custom-helper=api -out-root %T/DnnlUtils/api_test28_out %s --cuda-include-path="%cuda-path/include" -- -x cuda --cuda-host-only
2+
// RUN: grep "IsCalled" %T/DnnlUtils/api_test28_out/MainSourceFiles.yaml | wc -l > %T/DnnlUtils/api_test28_out/count.txt
3+
// RUN: FileCheck --input-file %T/DnnlUtils/api_test28_out/count.txt --match-full-lines %s
4+
// RUN: rm -rf %T/DnnlUtils/api_test28_out
5+
6+
7+
// CHECK: 2
8+
// TEST_FEATURE: DnnlUtils_get_version
9+
10+
#include <cuda_runtime.h>
11+
#include <cudnn.h>
12+
#include <iostream>
13+
#include <vector>
14+
15+
int main() {
16+
17+
size_t ver = cudnnGetVersion();
18+
return 0;
19+
20+
}

0 commit comments

Comments
 (0)