Skip to content

Commit 964fe7e

Browse files
Added lit test case for all cuTensor APIs
1 parent f846435 commit 964fe7e

1 file changed

Lines changed: 183 additions & 0 deletions

File tree

clang/test/dpct/cutensor.cu

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
// RUN: dpct --format-range=none --out-root=%T/cutensor %s --cuda-include-path="%cuda-path/include"
2+
// RUN: FileCheck %s --match-full-lines --input-file %T/cutensor/cutensor.dp.cpp
3+
#include <cstdio>
4+
#include <cutensor.h>
5+
6+
int main() {
7+
// Basic handle creation and destruction
8+
cutensorHandle_t handle;
9+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreate is not supported.
10+
cutensorCreate(&handle);
11+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorDestroy is not supported.
12+
cutensorDestroy(handle);
13+
14+
// Tensor descriptor
15+
cutensorTensorDescriptor_t tensorDesc;
16+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateTensorDescriptor is not supported.
17+
cutensorCreateTensorDescriptor(&tensorDesc);
18+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorDestroyTensorDescriptor is not supported.
19+
cutensorDestroyTensorDescriptor(tensorDesc);
20+
21+
// Get cuTENSOR versions and error strings
22+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorGetErrorString is not supported.
23+
const char *errStr = cutensorGetErrorString(CUTENSOR_STATUS_SUCCESS);
24+
printf("Error String: %s\n", errStr);
25+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorGetVersion is not supported.
26+
int version = cutensorGetVersion();
27+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorGetCudartVersion is not supported.
28+
int cudartVer = cutensorGetCudartVersion();
29+
printf("cuTENSOR Version: %d, CUDA Runtime Version: %d\n", version, cudartVer);
30+
31+
// Elementwise trinary operations
32+
cutensorElementwiseTrinaryDescriptor_t elemTrinaryDesc;
33+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateElementwiseTrinary is not supported.
34+
cutensorCreateElementwiseTrinary(&elemTrinaryDesc);
35+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorElementwiseTrinaryExecute is not supported.
36+
cutensorElementwiseTrinaryExecute(handle, elemTrinaryDesc, nullptr, 0);
37+
38+
// Elementwise binary operations
39+
cutensorElementwiseBinaryDescriptor_t elemBinaryDesc;
40+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateElementwiseBinary is not supported.
41+
cutensorCreateElementwiseBinary(&elemBinaryDesc);
42+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorElementwiseBinaryExecute is not supported.
43+
cutensorElementwiseBinaryExecute(handle, elemBinaryDesc, nullptr, 0);
44+
45+
// Permutation
46+
cutensorPermutationDescriptor_t permDesc;
47+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreatePermutation is not supported.
48+
cutensorCreatePermutation(&permDesc);
49+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorPermute is not supported.
50+
cutensorPermute(handle, permDesc, nullptr, 0);
51+
52+
// Contraction
53+
cutensorContractionDescriptor_t contractionDesc;
54+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateContraction is not supported.
55+
cutensorCreateContraction(&contractionDesc);
56+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorContract is not supported.
57+
cutensorContract(handle, contractionDesc, nullptr, 0);
58+
59+
// Contraction Trinary
60+
cutensorContractionTrinaryDescriptor_t contrTrinaryDesc;
61+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateContractionTrinary is not supported.
62+
cutensorCreateContractionTrinary(&contrTrinaryDesc);
63+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorContractTrinary is not supported.
64+
cutensorContractTrinary(handle, contrTrinaryDesc, nullptr, 0);
65+
66+
// Reduction
67+
cutensorReductionDescriptor_t reductionDesc;
68+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreateReduction is not supported.
69+
cutensorCreateReduction(&reductionDesc);
70+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorReduce is not supported.
71+
cutensorReduce(handle, reductionDesc, nullptr, 0);
72+
73+
// Operation descriptor functions
74+
cutensorOperationDescriptor_t opDesc = nullptr;
75+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorDestroyOperationDescriptor is not supported.
76+
cutensorDestroyOperationDescriptor(opDesc);
77+
int opAttr = 0;
78+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorOperationDescriptorGetAttribute is not supported.
79+
cutensorOperationDescriptorGetAttribute(opDesc, 0, &opAttr);
80+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorOperationDescriptorSetAttribute is not supported.
81+
cutensorOperationDescriptorSetAttribute(opDesc, 0, &opAttr);
82+
83+
// Plan preference functions
84+
cutensorPlanPreference_t planPref;
85+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreatePlanPreference is not supported.
86+
cutensorCreatePlanPreference(&planPref);
87+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorPlanPreferenceSetAttribute is not supported.
88+
cutensorPlanPreferenceSetAttribute(planPref, 0, &opAttr);
89+
size_t workspaceSize = 0;
90+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorEstimateWorkspaceSize is not supported.
91+
cutensorEstimateWorkspaceSize(handle, nullptr, &workspaceSize);
92+
cutensorPlan_t plan;
93+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorCreatePlan is not supported.
94+
cutensorCreatePlan(&plan);
95+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorPlanGetAttribute is not supported.
96+
cutensorPlanGetAttribute(plan, 0, &opAttr);
97+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorDestroyPlan is not supported.
98+
cutensorDestroyPlan(plan);
99+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorDestroyPlanPreference is not supported.
100+
cutensorDestroyPlanPreference(planPref);
101+
102+
// Plan cache management
103+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorHandleResizePlanCache is not supported.
104+
cutensorHandleResizePlanCache(handle, 0);
105+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorHandleReadPlanCacheFromFile is not supported.
106+
cutensorHandleReadPlanCacheFromFile(handle, "plan_cache.dat");
107+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorHandleWritePlanCacheToFile is not supported.
108+
cutensorHandleWritePlanCacheToFile(handle, "plan_cache.dat");
109+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorReadKernelCacheFromFile is not supported.
110+
cutensorReadKernelCacheFromFile(handle, "kernel_cache.dat");
111+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorWriteKernelCacheToFile is not supported.
112+
cutensorWriteKernelCacheToFile(handle, "kernel_cache.dat");
113+
114+
// Logger functions
115+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerSetCallback is not supported.
116+
cutensorLoggerSetCallback(nullptr);
117+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerSetFile is not supported.
118+
cutensorLoggerSetFile("logfile.txt");
119+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerOpenFile is not supported.
120+
cutensorLoggerOpenFile("logfile.txt");
121+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerSetLevel is not supported.
122+
cutensorLoggerSetLevel(0);
123+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerSetMask is not supported.
124+
cutensorLoggerSetMask(0);
125+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorLoggerForceDisable is not supported.
126+
cutensorLoggerForceDisable();
127+
128+
// Multi-grid (Mg) APIs
129+
// Mg handle creation and destruction
130+
cutensorMgHandle_t mgHandle;
131+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreate is not supported.
132+
cutensorMgCreate(&mgHandle);
133+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroy is not supported.
134+
cutensorMgDestroy(mgHandle);
135+
136+
// Mg tensor descriptor
137+
cutensorMgTensorDescriptor_t mgTensorDesc;
138+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateTensorDescriptor is not supported.
139+
cutensorMgCreateTensorDescriptor(&mgTensorDesc);
140+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyTensorDescriptor is not supported.
141+
cutensorMgDestroyTensorDescriptor(mgTensorDesc);
142+
143+
// Mg copy descriptor & plan
144+
cutensorMgCopyDescriptor_t mgCopyDesc;
145+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateCopyDescriptor is not supported.
146+
cutensorMgCreateCopyDescriptor(&mgCopyDesc);
147+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyCopyDescriptor is not supported.
148+
cutensorMgDestroyCopyDescriptor(mgCopyDesc);
149+
size_t mgCopyWorkspace = 0;
150+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCopyGetWorkspace is not supported.
151+
cutensorMgCopyGetWorkspace(mgCopyDesc, &mgCopyWorkspace);
152+
cutensorMgCopyPlan_t mgCopyPlan;
153+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateCopyPlan is not supported.
154+
cutensorMgCreateCopyPlan(&mgCopyPlan);
155+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyCopyPlan is not supported.
156+
cutensorMgDestroyCopyPlan(mgCopyPlan);
157+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCopy is not supported.
158+
cutensorMgCopy(handle, mgCopyPlan, nullptr, 0);
159+
160+
// Mg contraction descriptor, find, plan, and execution
161+
cutensorMgContractionDescriptor_t mgContrDesc;
162+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateContractionDescriptor is not supported.
163+
cutensorMgCreateContractionDescriptor(&mgContrDesc);
164+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyContractionDescriptor is not supported.
165+
cutensorMgDestroyContractionDescriptor(mgContrDesc);
166+
cutensorMgContractionFind_t mgContrFind;
167+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateContractionFind is not supported.
168+
cutensorMgCreateContractionFind(&mgContrFind);
169+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyContractionFind is not supported.
170+
cutensorMgDestroyContractionFind(mgContrFind);
171+
size_t mgContrWorkspace = 0;
172+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgContractionGetWorkspace is not supported.
173+
cutensorMgContractionGetWorkspace(mgContrDesc, &mgContrWorkspace);
174+
cutensorMgContractionPlan_t mgContrPlan;
175+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgCreateContractionPlan is not supported.
176+
cutensorMgCreateContractionPlan(&mgContrPlan);
177+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgDestroyContractionPlan is not supported.
178+
cutensorMgDestroyContractionPlan(mgContrPlan);
179+
// CHECK: DPCT1007:{{[0-9]+}}: Migration of cutensorMgContraction is not supported.
180+
cutensorMgContraction(handle, mgContrPlan, nullptr, 0);
181+
182+
return 0;
183+
}

0 commit comments

Comments
 (0)