mirror of
https://gitee.com/openharmony/third_party_opencl-headers
synced 2024-11-26 16:50:30 +00:00
Add tests and Travis CI config (#64)
* Add tests and Travis CI config The tests are copied from OpenCL-CTS. A small amount of additional CMake work will be needed to test on Windows as well. * Use non-system include paths for tests * Add more header tests
This commit is contained in:
parent
4ba6f9bee8
commit
b758718456
16
.travis.yml
Normal file
16
.travis.yml
Normal file
@ -0,0 +1,16 @@
|
||||
language: c
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- cmake ../tests
|
||||
- make
|
||||
- make test
|
35
tests/CMakeLists.txt
Normal file
35
tests/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
cmake_minimum_required (VERSION 2.8.11)
|
||||
|
||||
project(OpenCL_Headers_Tests)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/..)
|
||||
|
||||
# Make sure headers do not produce warnings
|
||||
add_compile_options(-Wall -Wextra -Werror -pedantic -Wno-format)
|
||||
|
||||
# Add a test for a given source file for each version of OpenCL
|
||||
function(add_header_test NAME SOURCE)
|
||||
foreach(VERSION 100 110 120 200 210 220)
|
||||
set(TEST_EXE ${NAME}_${VERSION})
|
||||
add_executable(${TEST_EXE} ${SOURCE})
|
||||
target_compile_definitions(${TEST_EXE}
|
||||
PUBLIC -DCL_TARGET_OPENCL_VERSION=${VERSION}
|
||||
)
|
||||
add_test(NAME ${TEST_EXE} COMMAND ${TEST_EXE})
|
||||
endforeach(VERSION)
|
||||
endfunction(add_header_test)
|
||||
|
||||
# Tests
|
||||
add_header_test(cl_h test_cl.h.c)
|
||||
add_header_test(cl_egl_h test_cl_egl.h.c)
|
||||
add_header_test(cl_ext_h test_cl_ext.h.c)
|
||||
add_header_test(cl_ext_intel_h test_cl_ext_intel.h.c)
|
||||
add_header_test(cl_gl_h test_cl_gl.h.c)
|
||||
add_header_test(cl_gl_ext_h test_cl_gl_ext.h.c)
|
||||
add_header_test(cl_icd_h test_cl_icd.h.c)
|
||||
add_header_test(cl_platform_h test_cl_platform.h.c)
|
||||
add_header_test(cl_opencl_h test_opencl.h.c)
|
||||
add_header_test(cl_version_h test_cl_version.h.c)
|
||||
add_header_test(headers test_headers.c)
|
22
tests/README.md
Normal file
22
tests/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
OpenCL-Headers/tests README
|
||||
===========================
|
||||
|
||||
The test_headers.c test is designed to make sure that the various cl_typen types
|
||||
work and conform to expectation for recent versions of cl_platform.h. Conforming
|
||||
to these expectations make use of these types practical for developers writing
|
||||
portable code.
|
||||
|
||||
The various tests ending in .h.c are there to verify that the various OpenCL
|
||||
headers can compile stand alone. That is to ensure that they may be used a la
|
||||
carte. This provides developers a lifeline in the case that some unneeded part
|
||||
of OpenCL (e.g. cl/gl sharing) brings in a pile of symbols (e.g. all of OpenGL)
|
||||
that collides with other headers needed by the application. It is also poor form
|
||||
to require headers to be included in a particular order, especially if multiple
|
||||
systems require they be included in mutually incompatible order. So, here we
|
||||
require that each header can be used standalone so that the order is irrelevant.
|
||||
|
||||
We also check to make sure that the headers don't cause spurious warnings. These
|
||||
tests are intended to be compiled using the most stringent compiler flags
|
||||
available for the platform, within reason. All warnings should be errors and
|
||||
extra warnings that it is expected developers are likely to use should be turned
|
||||
on.
|
25
tests/test_cl.h.c
Normal file
25
tests/test_cl.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_egl.h.c
Normal file
25
tests/test_cl_egl.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_egl.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_egl.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_ext.h.c
Normal file
25
tests/test_cl_ext.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_ext.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_ext.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_ext_intel.h.c
Normal file
25
tests/test_cl_ext_intel.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_ext_intel.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_ext_intel.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_gl.h.c
Normal file
25
tests/test_cl_gl.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_gl.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_gl.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_gl_ext.h.c
Normal file
25
tests/test_cl_gl_ext.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_gl_ext.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_gl_ext.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
31
tests/test_cl_icd.h.c
Normal file
31
tests/test_cl_icd.h.c
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_2_APIS
|
||||
#include "CL/cl_icd.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_icd.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_platform.h.c
Normal file
25
tests/test_cl_platform.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_platform.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_platform.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
25
tests/test_cl_version.h.c
Normal file
25
tests/test_cl_version.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl_version.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("cl_version.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
637
tests/test_headers.c
Normal file
637
tests/test_headers.c
Normal file
@ -0,0 +1,637 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
int test_char()
|
||||
{
|
||||
/* char */
|
||||
/* Constructor */
|
||||
cl_char a = 0;
|
||||
cl_char2 a2 = {{ 0, 1 }};
|
||||
cl_char4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_char8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_char16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_char b = a;
|
||||
cl_char2 b2 = a2;
|
||||
cl_char4 b4 = a4;
|
||||
cl_char8 b8 = a8;
|
||||
cl_char16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_CHAR2__ )
|
||||
__cl_char2 v2 = b2.v2;
|
||||
printf("__cl_char2: %d %d \n", ((cl_char*)&v2)[0], ((cl_char*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_char2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_CHAR4__ )
|
||||
__cl_char4 v4 = b4.v4;
|
||||
printf("__cl_char4: %d %d %d %d \n", ((cl_char*)&v4)[0], ((cl_char*)&v4)[1], ((cl_char*)&v4)[2], ((cl_char*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_char4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_CHAR8__ )
|
||||
__cl_char8 v8 = b8.v8;
|
||||
printf("__cl_char8: %d %d %d %d %d %d %d %d \n", ((cl_char*)&v8)[0], ((cl_char*)&v8)[1], ((cl_char*)&v8)[2], ((cl_char*)&v8)[3], ((cl_char*)&v8)[4], ((cl_char*)&v8)[5], ((cl_char*)&v8)[6], ((cl_char*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_char8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_CHAR16__ )
|
||||
__cl_char16 v16 = b16.v16;
|
||||
printf("__cl_char16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_char*)&v16)[0], ((cl_char*)&v16)[1], ((cl_char*)&v16)[2], ((cl_char*)&v16)[3], ((cl_char*)&v16)[4], ((cl_char*)&v16)[5], ((cl_char*)&v16)[6], ((cl_char*)&v16)[7],
|
||||
((cl_char*)&v16)[8], ((cl_char*)&v16)[9], ((cl_char*)&v16)[10], ((cl_char*)&v16)[11], ((cl_char*)&v16)[12], ((cl_char*)&v16)[13], ((cl_char*)&v16)[14], ((cl_char*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_char16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_uchar()
|
||||
{
|
||||
/* uchar */
|
||||
/* Constructor */
|
||||
cl_uchar a = 0;
|
||||
cl_uchar2 a2 = {{ 0, 1 }};
|
||||
cl_uchar4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_uchar8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_uchar16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_uchar b = a;
|
||||
cl_uchar2 b2 = a2;
|
||||
cl_uchar4 b4 = a4;
|
||||
cl_uchar8 b8 = a8;
|
||||
cl_uchar16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_UCHAR2__ )
|
||||
__cl_uchar2 v2 = b2.v2;
|
||||
printf("__cl_uchar2: %d %d \n", ((uchar*)&v2)[0], ((cl_uchar*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_uchar2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UCHAR4__ )
|
||||
__cl_uchar4 v4 = b4.v4;
|
||||
printf("__cl_uchar4: %d %d %d %d \n", ((uchar*)&v4)[0], ((cl_uchar*)&v4)[1], ((cl_uchar*)&v4)[2], ((cl_uchar*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_uchar4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UCHAR8__ )
|
||||
__cl_uchar8 v8 = b8.v8;
|
||||
printf("__cl_uchar8: %d %d %d %d %d %d %d %d \n", ((cl_uchar*)&v8)[0], ((cl_uchar*)&v8)[1], ((cl_uchar*)&v8)[2], ((cl_uchar*)&v8)[3], ((cl_uchar*)&v8)[4], ((cl_uchar*)&v8)[5], ((cl_uchar*)&v8)[6], ((cl_uchar*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_uchar8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UCHAR16__ )
|
||||
__cl_uchar16 v16 = b16.v16;
|
||||
printf("__cl_uchar16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_uchar*)&v16)[0], ((cl_uchar*)&v16)[1], ((cl_uchar*)&v16)[2], ((cl_uchar*)&v16)[3], ((cl_uchar*)&v16)[4], ((cl_uchar*)&v16)[5], ((cl_uchar*)&v16)[6], ((cl_uchar*)&v16)[7],
|
||||
((cl_uchar*)&v16)[8], ((cl_uchar*)&v16)[9], ((cl_uchar*)&v16)[10], ((cl_uchar*)&v16)[11], ((cl_uchar*)&v16)[12], ((cl_uchar*)&v16)[13], ((cl_uchar*)&v16)[14], ((cl_uchar*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_uchar16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_short()
|
||||
{
|
||||
/* short */
|
||||
/* Constructor */
|
||||
cl_short a = 0;
|
||||
cl_short2 a2 = {{ 0, 1 }};
|
||||
cl_short4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_short8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_short16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_short b = a;
|
||||
cl_short2 b2 = a2;
|
||||
cl_short4 b4 = a4;
|
||||
cl_short8 b8 = a8;
|
||||
cl_short16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_SHORT2__ )
|
||||
__cl_short2 v2 = b2.v2;
|
||||
printf("__cl_short2: %d %d \n", ((cl_short*)&v2)[0], ((cl_short*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_short2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_SHORT4__ )
|
||||
__cl_short4 v4 = b4.v4;
|
||||
printf("__cl_short4: %d %d %d %d \n", ((cl_short*)&v4)[0], ((cl_short*)&v4)[1], ((cl_short*)&v4)[2], ((cl_short*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_short4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_SHORT8__ )
|
||||
__cl_short8 v8 = b8.v8;
|
||||
printf("__cl_short8: %d %d %d %d %d %d %d %d \n", ((cl_short*)&v8)[0], ((cl_short*)&v8)[1], ((cl_short*)&v8)[2], ((cl_short*)&v8)[3], ((cl_short*)&v8)[4], ((cl_short*)&v8)[5], ((cl_short*)&v8)[6], ((cl_short*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_short8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_SHORT16__ )
|
||||
__cl_short16 v16 = b16.v16;
|
||||
printf("__cl_short16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_short*)&v16)[0], ((cl_short*)&v16)[1], ((cl_short*)&v16)[2], ((cl_short*)&v16)[3], ((cl_short*)&v16)[4], ((cl_short*)&v16)[5], ((cl_short*)&v16)[6], ((cl_short*)&v16)[7],
|
||||
((cl_short*)&v16)[8], ((cl_short*)&v16)[9], ((cl_short*)&v16)[10], ((cl_short*)&v16)[11], ((cl_short*)&v16)[12], ((cl_short*)&v16)[13], ((cl_short*)&v16)[14], ((cl_short*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_short16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_ushort()
|
||||
{
|
||||
/* ushort */
|
||||
/* Constructor */
|
||||
cl_ushort a = 0;
|
||||
cl_ushort2 a2 = {{ 0, 1 }};
|
||||
cl_ushort4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_ushort8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_ushort16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_ushort b = a;
|
||||
cl_ushort2 b2 = a2;
|
||||
cl_ushort4 b4 = a4;
|
||||
cl_ushort8 b8 = a8;
|
||||
cl_ushort16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_USHORT2__ )
|
||||
__cl_ushort2 v2 = b2.v2;
|
||||
printf("__cl_ushort2: %d %d \n", ((unsigned short*)&v2)[0], ((unsigned short*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_ushort2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_USHORT4__ )
|
||||
__cl_ushort4 v4 = b4.v4;
|
||||
printf("__cl_ushort4: %d %d %d %d \n", ((unsigned short*)&v4)[0], ((unsigned short*)&v4)[1], ((unsigned short*)&v4)[2], ((unsigned short*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_ushort4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_USHORT8__ )
|
||||
__cl_ushort8 v8 = b8.v8;
|
||||
printf("__cl_ushort8: %d %d %d %d %d %d %d %d \n", ((unsigned short*)&v8)[0], ((unsigned short*)&v8)[1], ((unsigned short*)&v8)[2], ((unsigned short*)&v8)[3], ((unsigned short*)&v8)[4], ((unsigned short*)&v8)[5], ((unsigned short*)&v8)[6], ((unsigned short*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_ushort8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_USHORT16__ )
|
||||
__cl_ushort16 v16 = b16.v16;
|
||||
printf("__cl_ushort16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((unsigned short*)&v16)[0], ((unsigned short*)&v16)[1], ((unsigned short*)&v16)[2], ((unsigned short*)&v16)[3], ((unsigned short*)&v16)[4], ((unsigned short*)&v16)[5], ((unsigned short*)&v16)[6], ((unsigned short*)&v16)[7],
|
||||
((unsigned short*)&v16)[8], ((unsigned short*)&v16)[9], ((unsigned short*)&v16)[10], ((unsigned short*)&v16)[11], ((unsigned short*)&v16)[12], ((unsigned short*)&v16)[13], ((unsigned short*)&v16)[14], ((unsigned short*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_ushort16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_int()
|
||||
{
|
||||
/* int */
|
||||
/* Constructor */
|
||||
cl_int a = 0;
|
||||
cl_int2 a2 = {{ 0, 1 }};
|
||||
cl_int4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_int8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_int16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_int b = a;
|
||||
cl_int2 b2 = a2;
|
||||
cl_int4 b4 = a4;
|
||||
cl_int8 b8 = a8;
|
||||
cl_int16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_INT2__ )
|
||||
__cl_int2 v2 = b2.v2;
|
||||
printf("__cl_int2: %d %d \n", ((cl_int*)&v2)[0], ((cl_int*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_int2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_INT4__ )
|
||||
__cl_int4 v4 = b4.v4;
|
||||
printf("__cl_int4: %d %d %d %d \n", ((cl_int*)&v4)[0], ((cl_int*)&v4)[1], ((cl_int*)&v4)[2], ((cl_int*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_int4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_INT8__ )
|
||||
__cl_int8 v8 = b8.v8;
|
||||
printf("__cl_int8: %d %d %d %d %d %d %d %d \n", ((cl_int*)&v8)[0], ((cl_int*)&v8)[1], ((cl_int*)&v8)[2], ((cl_int*)&v8)[3], ((cl_int*)&v8)[4], ((cl_int*)&v8)[5], ((cl_int*)&v8)[6], ((cl_int*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_int8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_INT16__ )
|
||||
__cl_int16 v16 = b16.v16;
|
||||
printf("__cl_int16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_int*)&v16)[0], ((cl_int*)&v16)[1], ((cl_int*)&v16)[2], ((cl_int*)&v16)[3], ((cl_int*)&v16)[4], ((cl_int*)&v16)[5], ((cl_int*)&v16)[6], ((cl_int*)&v16)[7],
|
||||
((cl_int*)&v16)[8], ((cl_int*)&v16)[9], ((cl_int*)&v16)[10], ((cl_int*)&v16)[11], ((cl_int*)&v16)[12], ((cl_int*)&v16)[13], ((cl_int*)&v16)[14], ((cl_int*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_int16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_uint()
|
||||
{
|
||||
/* uint */
|
||||
/* Constructor */
|
||||
cl_uint a = 0;
|
||||
cl_uint2 a2 = {{ 0, 1 }};
|
||||
cl_uint4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_uint8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_uint16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_uint b = a;
|
||||
cl_uint2 b2 = a2;
|
||||
cl_uint4 b4 = a4;
|
||||
cl_uint8 b8 = a8;
|
||||
cl_uint16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %d\n", b );
|
||||
printf("b2: %d %d \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %d %d %d %d\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %d %d %d %d %d %d %d %d\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_UINT2__ )
|
||||
__cl_uint2 v2 = b2.v2;
|
||||
printf("__cl_uint2: %d %d \n", ((cl_uint*)&v2)[0], ((cl_uint*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_uint2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UINT4__ )
|
||||
__cl_uint4 v4 = b4.v4;
|
||||
printf("__cl_uint4: %d %d %d %d \n", ((cl_uint*)&v4)[0], ((cl_uint*)&v4)[1], ((cl_uint*)&v4)[2], ((cl_uint*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_uint4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UINT8__ )
|
||||
__cl_uint8 v8 = b8.v8;
|
||||
printf("__cl_uint8: %d %d %d %d %d %d %d %d \n", ((cl_uint*)&v8)[0], ((cl_uint*)&v8)[1], ((cl_uint*)&v8)[2], ((cl_uint*)&v8)[3], ((cl_uint*)&v8)[4], ((cl_uint*)&v8)[5], ((cl_uint*)&v8)[6], ((cl_uint*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_uint8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_UINT16__ )
|
||||
__cl_uint16 v16 = b16.v16;
|
||||
printf("__cl_uint16: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", ((cl_uint*)&v16)[0], ((cl_uint*)&v16)[1], ((cl_uint*)&v16)[2], ((cl_uint*)&v16)[3], ((cl_uint*)&v16)[4], ((cl_uint*)&v16)[5], ((cl_uint*)&v16)[6], ((cl_uint*)&v16)[7],
|
||||
((cl_uint*)&v16)[8], ((cl_uint*)&v16)[9], ((cl_uint*)&v16)[10], ((cl_uint*)&v16)[11], ((cl_uint*)&v16)[12], ((cl_uint*)&v16)[13], ((cl_uint*)&v16)[14], ((cl_uint*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_uint16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_long()
|
||||
{
|
||||
/* long */
|
||||
/* Constructor */
|
||||
cl_long a = 0;
|
||||
cl_long2 a2 = {{ 0, 1 }};
|
||||
cl_long4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_long8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_long16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_long b = a;
|
||||
cl_long2 b2 = a2;
|
||||
cl_long4 b4 = a4;
|
||||
cl_long8 b8 = a8;
|
||||
cl_long16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %lld\n", b );
|
||||
printf("b2: %lld %lld \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %lld %lld %lld %lld\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %lld %lld %lld %lld %lld %lld %lld %lld\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_LONG2__ )
|
||||
__cl_long2 v2 = b2.v2;
|
||||
printf("__cl_long2: %lld %lld \n", ((cl_long*)&v2)[0], ((cl_long*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_long2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_LONG4__ )
|
||||
__cl_long4 v4 = b4.v4;
|
||||
printf("__cl_long4: %lld %lld %lld %lld \n", ((cl_long*)&v4)[0], ((cl_long*)&v4)[1], ((cl_long*)&v4)[2], ((cl_long*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_long4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_LONG8__ )
|
||||
__cl_long8 v8 = b8.v8;
|
||||
printf("__cl_long8: %lld %lld %lld %lld %lld %lld %lld %lld \n", ((cl_long*)&v8)[0], ((cl_long*)&v8)[1], ((cl_long*)&v8)[2], ((cl_long*)&v8)[3], ((cl_long*)&v8)[4], ((cl_long*)&v8)[5], ((cl_long*)&v8)[6], ((cl_long*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_long8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_LONG16__ )
|
||||
__cl_long16 v16 = b16.v16;
|
||||
printf("__cl_long16: %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld \n", ((cl_long*)&v16)[0], ((cl_long*)&v16)[1], ((cl_long*)&v16)[2], ((cl_long*)&v16)[3], ((cl_long*)&v16)[4], ((cl_long*)&v16)[5], ((cl_long*)&v16)[6], ((cl_long*)&v16)[7],
|
||||
((cl_long*)&v16)[8], ((cl_long*)&v16)[9], ((cl_long*)&v16)[10], ((cl_long*)&v16)[11], ((cl_long*)&v16)[12], ((cl_long*)&v16)[13], ((cl_long*)&v16)[14], ((cl_long*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_long16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_ulong()
|
||||
{
|
||||
/* ulong */
|
||||
/* Constructor */
|
||||
cl_ulong a = 0;
|
||||
cl_ulong2 a2 = {{ 0, 1 }};
|
||||
cl_ulong4 a4 = {{ 0, 1, 2, 3 }};
|
||||
cl_ulong8 a8 = {{ 0, 1, 2, 3, 4, 5, 6, 7 }};
|
||||
cl_ulong16 a16 = {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }};
|
||||
|
||||
/* assignment */
|
||||
cl_ulong b = a;
|
||||
cl_ulong2 b2 = a2;
|
||||
cl_ulong4 b4 = a4;
|
||||
cl_ulong8 b8 = a8;
|
||||
cl_ulong16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %lld\n", b );
|
||||
printf("b2: %lld %lld \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %lld %lld %lld %lld\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %lld %lld %lld %lld %lld %lld %lld %lld\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_ULONG2__ )
|
||||
__cl_ulong2 v2 = b2.v2;
|
||||
printf("__cl_ulong2: %lld %lld \n", ((cl_ulong*)&v2)[0], ((cl_ulong*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_ulong2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_ULONG4__ )
|
||||
__cl_ulong4 v4 = b4.v4;
|
||||
printf("__cl_ulong4: %lld %lld %lld %lld \n", ((cl_ulong*)&v4)[0], ((cl_ulong*)&v4)[1], ((cl_ulong*)&v4)[2], ((cl_ulong*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_ulong4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_ULONG8__ )
|
||||
__cl_ulong8 v8 = b8.v8;
|
||||
printf("__cl_ulong8: %lld %lld %lld %lld %lld %lld %lld %lld \n", ((cl_ulong*)&v8)[0], ((cl_ulong*)&v8)[1], ((cl_ulong*)&v8)[2], ((cl_ulong*)&v8)[3], ((cl_ulong*)&v8)[4], ((cl_ulong*)&v8)[5], ((cl_ulong*)&v8)[6], ((cl_ulong*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_ulong8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_ULONG16__ )
|
||||
__cl_ulong16 v16 = b16.v16;
|
||||
printf("__cl_ulong16: %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld \n", ((cl_ulong*)&v16)[0], ((cl_ulong*)&v16)[1], ((cl_ulong*)&v16)[2], ((cl_ulong*)&v16)[3], ((cl_ulong*)&v16)[4], ((cl_ulong*)&v16)[5], ((cl_ulong*)&v16)[6], ((cl_ulong*)&v16)[7],
|
||||
((cl_ulong*)&v16)[8], ((cl_ulong*)&v16)[9], ((cl_ulong*)&v16)[10], ((cl_ulong*)&v16)[11], ((cl_ulong*)&v16)[12], ((cl_ulong*)&v16)[13], ((cl_ulong*)&v16)[14], ((cl_ulong*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_ulong16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_float()
|
||||
{
|
||||
/* float */
|
||||
/* Constructor */
|
||||
cl_float a = 0.0f;
|
||||
cl_float2 a2 = {{ 0.0f, 1.0f }};
|
||||
cl_float4 a4 = {{ 0.0f, 1.0f, 2.0f, 3.0f }};
|
||||
cl_float8 a8 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }};
|
||||
cl_float16 a16 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }};
|
||||
|
||||
/* assignment */
|
||||
cl_float b = a;
|
||||
cl_float2 b2 = a2;
|
||||
cl_float4 b4 = a4;
|
||||
cl_float8 b8 = a8;
|
||||
cl_float16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %f\n", b );
|
||||
printf("b2: %f %f \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %f %f %f %f\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %f %f %f %f %f %f %f %f\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_FLOAT2__ )
|
||||
__cl_float2 v2 = b2.v2;
|
||||
printf("__cl_float2: %f %f \n", ((cl_float*)&v2)[0], ((cl_float*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_float2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_FLOAT4__ )
|
||||
{
|
||||
__cl_float4 v4 = b4.v4;
|
||||
printf("__cl_float4: %f %f %f %f \n", ((cl_float*)&v4)[0], ((cl_float*)&v4)[1], ((cl_float*)&v4)[2], ((cl_float*)&v4)[3] );
|
||||
}
|
||||
#else
|
||||
printf( "__cl_float4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_FLOAT8__ )
|
||||
__cl_float8 v8 = b8.v8;
|
||||
printf("__cl_float8: %f %f %f %f %f %f %f %f \n", ((cl_float*)&v8)[0], ((cl_float*)&v8)[1], ((cl_float*)&v8)[2], ((cl_float*)&v8)[3], ((cl_float*)&v8)[4], ((cl_float*)&v8)[5], ((cl_float*)&v8)[6], ((cl_float*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_float8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_FLOAT16__ )
|
||||
__cl_float16 v16 = b16.v16;
|
||||
printf("__cl_float16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n", ((cl_float*)&v16)[0], ((cl_float*)&v16)[1], ((cl_float*)&v16)[2], ((cl_float*)&v16)[3], ((cl_float*)&v16)[4], ((cl_float*)&v16)[5], ((cl_float*)&v16)[6], ((cl_float*)&v16)[7],
|
||||
((cl_float*)&v16)[8], ((cl_float*)&v16)[9], ((cl_float*)&v16)[10], ((cl_float*)&v16)[11], ((cl_float*)&v16)[12], ((cl_float*)&v16)[13], ((cl_float*)&v16)[14], ((cl_float*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_float16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_double()
|
||||
{
|
||||
/* double */
|
||||
/* Constructor */
|
||||
cl_double a = 0.0f;
|
||||
cl_double2 a2 = {{ 0.0f, 1.0f }};
|
||||
cl_double4 a4 = {{ 0.0f, 1.0f, 2.0f, 3.0f }};
|
||||
cl_double8 a8 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }};
|
||||
cl_double16 a16 = {{ 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }};
|
||||
|
||||
/* assignment */
|
||||
cl_double b = a;
|
||||
cl_double2 b2 = a2;
|
||||
cl_double4 b4 = a4;
|
||||
cl_double8 b8 = a8;
|
||||
cl_double16 b16 = a16;
|
||||
|
||||
printf("\nVerifying assignment:\n" );
|
||||
printf("b: %f\n", b );
|
||||
printf("b2: %f %f \n", b2.s[0], b2.s[1] );
|
||||
printf("b4: %f %f %f %f\n", b4.s[0], b4.s[1], b4.s[2], b4.s[3] );
|
||||
printf("b8: %f %f %f %f %f %f %f %f\n", b8.s[0], b8.s[1], b8.s[2], b8.s[3], b8.s[4], b8.s[5], b8.s[6], b8.s[7] );
|
||||
printf("b16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", b16.s[0], b16.s[1], b16.s[2], b16.s[3], b16.s[4], b16.s[5], b16.s[6], b16.s[7],
|
||||
b16.s[8], b16.s[9], b16.s[10], b16.s[11], b16.s[12], b16.s[13], b16.s[14], b16.s[15]);
|
||||
|
||||
/* vector access */
|
||||
printf("\nVerifying vector access:\n" );
|
||||
#if defined( __CL_DOUBLE2__ )
|
||||
__cl_double2 v2 = b2.v2;
|
||||
printf("__cl_double2: %f %f \n", ((cl_double*)&v2)[0], ((cl_double*)&v2)[1] );
|
||||
#else
|
||||
printf( "__cl_double2 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_DOUBLE4__ )
|
||||
__cl_double4 v4 = b4.v4;
|
||||
printf("__cl_double4: %f %f %f %f \n", ((cl_double*)&v4)[0], ((cl_double*)&v4)[1], ((cl_double*)&v4)[2], ((cl_double*)&v4)[3] );
|
||||
#else
|
||||
printf( "__cl_double4 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_DOUBLE8__ )
|
||||
__cl_double8 v8 = b8.v8;
|
||||
printf("__cl_double8: %f %f %f %f %f %f %f %f \n", ((cl_double*)&v8)[0], ((cl_double*)&v8)[1], ((cl_double*)&v8)[2], ((cl_double*)&v8)[3], ((cl_double*)&v8)[4], ((cl_double*)&v8)[5], ((cl_double*)&v8)[6], ((cl_double*)&v8)[7] );
|
||||
#else
|
||||
printf( "__cl_double8 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
#if defined( __CL_DOUBLE16__ )
|
||||
__cl_double16 v16 = b16.v16;
|
||||
printf("__cl_double16: %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n", ((cl_double*)&v16)[0], ((cl_double*)&v16)[1], ((cl_double*)&v16)[2], ((cl_double*)&v16)[3], ((cl_double*)&v16)[4], ((cl_double*)&v16)[5], ((cl_double*)&v16)[6], ((cl_double*)&v16)[7],
|
||||
((cl_double*)&v16)[8], ((cl_double*)&v16)[9], ((cl_double*)&v16)[10], ((cl_double*)&v16)[11], ((cl_double*)&v16)[12], ((cl_double*)&v16)[13], ((cl_double*)&v16)[14], ((cl_double*)&v16)[15]);
|
||||
#else
|
||||
printf( "__cl_double16 SIMD vectors not supported on this architecture.\n" );
|
||||
#endif
|
||||
|
||||
printf( "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf( "\nChecking operations on cl_types.\nNumbers, where presented, should walk upward from 0, with step of 1:\n" );
|
||||
|
||||
test_char();
|
||||
test_uchar();
|
||||
test_short();
|
||||
test_ushort();
|
||||
test_long();
|
||||
test_ulong();
|
||||
test_float();
|
||||
test_double();
|
||||
|
||||
return 0;
|
||||
}
|
25
tests/test_opencl.h.c
Normal file
25
tests/test_opencl.h.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) 2020 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CL/opencl.h"
|
||||
|
||||
int main( void )
|
||||
{
|
||||
printf("opencl.h standalone test PASSED.\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user