10000 [SYCLomatic #146] Add E2E test for texture object feature · oneapi-src/SYCLomatic-test@093d525 · GitHub
[go: up one dir, main page]

Skip to content

Commit 093d525

Browse files
authored
[SYCLomatic #146] Add E2E test for texture object feature
2 parents 8683f7a + 10005fe commit 093d525

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

features/config/TEMPLATE_image.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<test driverID="test_feature" name="TEMPLATE">
4+
<description>test</description>
5+
<files>
6+
<file path="feature_case/image/image.cu" />
7+
</files>
8+
</test>
9+

features/feature_case/image/image.cu

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
struct TexList {
3+
cudaTextureObject_t tex1;
4+
cudaTextureObject_t tex2;
5+
cudaTextureObject_t tex3;
6+
};
7+
8+
__device__ void texlist_device(TexList list) {
9+
int a;
10+
tex1Dfetch(&a, list.tex1, 1);
11+
}
12+
13+
__global__ void texlist_kernel(TexList list) {
14+
int b;
15+
texlist_device(list);
16+
tex1Dfetch(&b, list.tex2, 1);
17+
tex1Dfetch(&b, list.tex3, 1);
18+
}
19+
20+
cudaTextureObject_t createTexture(int *data, size_t size) {
21+
cudaTextureObject_t tex;
22+
cudaResourceDesc res;
23+
cudaTextureDesc desc;
24+
res.resType = cudaResourceTypeLinear;
25+
res.res.linear.devPtr = data;
26+
res.res.linear.desc.f = cudaChannelFormatKindSigned;
27+
res.res.linear.desc.x = sizeof(int) * 8; // bits per channel
28+
res.res.linear.sizeInBytes = 32 * sizeof(int);
29+
desc.addressMode[0] = cudaAddressModeClamp;
30+
desc.addressMode[1] = cudaAddressModeClamp;
31+
desc.addressMode[2] = cudaAddressModeClamp;
32+
desc.filterMode = cudaFilterModeLinear;
33+
cudaCreateTextureObject(&tex, &res, &desc, NULL);
34+
return tex;
35+
}
36+
37+
void test(TexList list) {
38+
texlist_kernel<<<1, 1>>>(list);
39+
}
40+
41+
int main() {
42+
TexList tex;
43+
int data[32];
44+
for (unsigned i = 0; i < 32; ++i)
45+
data[i] = i;
46+
47+
tex.tex1 = createTexture(data, 32);
48+
tex.tex2 = createTexture(data, 32);
49+
tex.tex3 = createTexture(data, 32);
50+
test(tex);
51+
}
52+
53+

features/features.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@
358358
<!-- <test testName="cufft_test" configFile="config/TEMPLATE_fft_runable.xml" splitGroup="double"/> -->
359359
<test testName="libcu_atomic" configFile="config/TEMPLATE_libcu.xml" />
360360
<test testName="pointer_attributes" configFile="config/TEMPLATE_pointer_attributes.xml" />
361+
<test testName="image" configFile="config/TEMPLATE_image.xml" />
361362
<test testName="math_intel_specific" configFile="config/TEMPLATE_math_intel_specific.xml" />
362363
</tests>
363364
</suite>

0 commit comments

Comments
 (0)
0