Files
OpenCL-CTS/test_conformance/compiler/test_image_macro.c
Kevin Petit d8733efc0f Synchronise with Khronos-private Gitlab branch
The maintenance of the conformance tests is moving to Github.

This commit contains all the changes that have been done in
Gitlab since the first public release of the conformance tests.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2019-03-05 16:23:49 +00:00

96 lines
2.9 KiB
C

//
// Copyright (c) 2017 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 "testBase.h"
#if (defined( __APPLE__ ) || defined( __linux__ ))
#include <unistd.h>
#endif
const char * image_supported_source = "kernel void enabled(global int * buf) { \r\n" \
"int n = get_global_id(0); \r\n"\
"buf[n] = 0; \r\n "\
"#ifndef __IMAGE_SUPPORT__ \r\n" \
"ERROR; \r\n"\
"#endif \r\n"\
"\r\n } \r\n";
const char * image_not_supported_source = "kernel void not_enabled(global int * buf) { \r\n" \
"int n = get_global_id(0); \r\n"\
"buf[n] = 0; \r\n "\
"#ifdef __IMAGE_SUPPORT__ \r\n" \
"ERROR; \r\n"\
"#endif \r\n"\
"\r\n } \r\n";
int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
cl_bool image_support;
char buf[256];
int status;
cl_program program;
status = clGetDeviceInfo( deviceID, CL_DEVICE_NAME, sizeof( buf ), buf, NULL );
if( status )
{
log_error( "getting device info (name): %d\n", status );
exit(-1);
}
status = clGetDeviceInfo( deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof( image_support ), &image_support, NULL );
if( status )
{
log_error( "getting device info (image support): %d\n", status );
return status;
}
if( (image_support == CL_TRUE) )
{
program = clCreateProgramWithSource( context, 1, (const char**) &image_supported_source, NULL, &status );
if( status )
{
log_error ("Failure creating program, [%d] \n", status );
return status;
}
status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
if( status )
log_error("CL_DEVICE_IMAGE_SUPPORT is set, __IMAGE_SUPPORT__ macro not set \n");
else
log_info("CL_DEVICE_IMAGE_SUPPORT is set, __IMAGE_SUPPORT__ macro is set \n");
}
else
{
program = clCreateProgramWithSource( context, 1, (const char**) &image_not_supported_source, NULL, &status );
if( status )
{
log_error ("Failure creating program, [%d] \n", status );
return status;
}
status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
if( status )
log_error("CL_DEVICE_IMAGE_SUPPORT not set, __IMAGE_SUPPORT__ macro is set \n");
else
log_info("CL_DEVICE_IMAGE_SUPPORT not set, __IMAGE_SUPPORT__ macro not set \n");
}
clReleaseProgram( program );
return status;
}