|
Packit |
6d72ef |
/**
|
|
Packit |
6d72ef |
Copyright (c) 2012, Brice Videau <brice.videau@imag.fr>
|
|
Packit |
6d72ef |
Copyright (c) 2012, Vincent Danjean <Vincent.Danjean@ens-lyon.org>
|
|
Packit |
6d72ef |
All rights reserved.
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
6d72ef |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
1. Redistributions of source code must retain the above copyright notice, this
|
|
Packit |
6d72ef |
list of conditions and the following disclaimer.
|
|
Packit |
6d72ef |
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
6d72ef |
this list of conditions and the following disclaimer in the documentation
|
|
Packit |
6d72ef |
and/or other materials provided with the distribution.
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
Packit |
6d72ef |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
Packit |
6d72ef |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
6d72ef |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
Packit |
6d72ef |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
Packit |
6d72ef |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
Packit |
6d72ef |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
Packit |
6d72ef |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit |
6d72ef |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit |
6d72ef |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
6d72ef |
*/
|
|
Packit |
6d72ef |
#include <stdlib.h>
|
|
Packit |
6d72ef |
#include <stdio.h>
|
|
Packit |
6d72ef |
#pragma GCC diagnostic push
|
|
Packit |
6d72ef |
# pragma GCC diagnostic ignored "-Wcpp"
|
|
Packit |
6d72ef |
# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
|
Packit |
6d72ef |
# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
|
Packit |
6d72ef |
# include <CL/opencl.h>
|
|
Packit |
6d72ef |
# include <CL/cl.h>
|
|
Packit |
6d72ef |
# include <CL/cl_gl.h>
|
|
Packit |
6d72ef |
# include <CL/cl_egl.h>
|
|
Packit |
6d72ef |
# include <CL/cl_ext.h>
|
|
Packit |
6d72ef |
# include <CL/cl_gl_ext.h>
|
|
Packit |
6d72ef |
#pragma GCC diagnostic pop
|
|
Packit |
6d72ef |
#include <string.h>
|
|
Packit |
6d72ef |
#include "ocl_icd_debug.h"
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
extern void call_all_OpenCL_functions(cl_platform_id chosen_platform);
|
|
Packit |
6d72ef |
int debug_ocl_icd_mask;
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
int main(void) {
|
|
Packit |
6d72ef |
int i;
|
|
Packit |
6d72ef |
cl_uint num_platforms;
|
|
Packit |
6d72ef |
debug_init();
|
|
Packit |
6d72ef |
clGetPlatformIDs( 0, NULL, &num_platforms);
|
|
Packit |
6d72ef |
cl_platform_id *platforms = malloc(sizeof(cl_platform_id) * num_platforms);
|
|
Packit |
6d72ef |
clGetPlatformIDs(num_platforms, platforms, NULL);
|
|
Packit |
6d72ef |
debug(D_LOG, "Found %d platforms.", num_platforms);
|
|
Packit |
6d72ef |
cl_platform_id chosen_platform=NULL;
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
for(i=0; i
|
|
Packit |
6d72ef |
char *platform_vendor;
|
|
Packit |
6d72ef |
size_t param_value_size_ret;
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, 0, NULL, ¶m_value_size_ret );
|
|
Packit |
6d72ef |
platform_vendor = (char *)malloc(param_value_size_ret);
|
|
Packit |
6d72ef |
clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, param_value_size_ret, platform_vendor, NULL );
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
debug(D_LOG, "platform_vendor: %s",platform_vendor);
|
|
Packit |
6d72ef |
if( strcmp(platform_vendor, "ocl-icd ICD test") == 0)
|
|
Packit |
6d72ef |
chosen_platform = platforms[i];
|
|
Packit |
6d72ef |
free(platform_vendor);
|
|
Packit |
6d72ef |
}
|
|
Packit |
6d72ef |
if( chosen_platform == NULL ) {
|
|
Packit |
6d72ef |
fprintf(stderr,"Error LIG platform not found!\n");
|
|
Packit |
6d72ef |
return -1;
|
|
Packit |
6d72ef |
}
|
|
Packit |
6d72ef |
|
|
Packit |
6d72ef |
printf("---\n");
|
|
Packit |
6d72ef |
fflush(NULL);
|
|
Packit |
6d72ef |
call_all_OpenCL_functions(chosen_platform);
|
|
Packit |
6d72ef |
return 0;
|
|
Packit |
6d72ef |
}
|