Static-const-ify ICD loader info strings
[ocl-icd] / run_dummy_icd.c
1 /**
2 Copyright (c) 2012, Brice Videau <brice.videau@imag.fr>
3 Copyright (c) 2012, Vincent Danjean <Vincent.Danjean@ens-lyon.org>
4 All rights reserved.
5       
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8     
9 1. Redistributions of source code must retain the above copyright notice, this
10    list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright notice,
12    this list of conditions and the following disclaimer in the documentation
13    and/or other materials provided with the distribution.
14         
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <stdlib.h>
27 #include <stdio.h>
28 #pragma GCC diagnostic push
29 #  pragma GCC diagnostic ignored "-Wcpp"
30 #  define CL_USE_DEPRECATED_OPENCL_1_0_APIS
31 #  define CL_USE_DEPRECATED_OPENCL_1_1_APIS
32 #  include <CL/opencl.h>
33 #  include <CL/cl.h>
34 #  include <CL/cl_gl.h>
35 #  include <CL/cl_egl.h>
36 #  include <CL/cl_ext.h>
37 #  include <CL/cl_gl_ext.h>
38 #pragma GCC diagnostic pop
39 #include <string.h>
40 #include "ocl_icd_debug.h"
41
42 extern void call_all_OpenCL_functions(cl_platform_id chosen_platform);
43 int debug_ocl_icd_mask;
44
45 int main(void) {
46   int i;
47   cl_uint num_platforms;
48   debug_init();
49   clGetPlatformIDs( 0, NULL, &num_platforms);
50   cl_platform_id *platforms = malloc(sizeof(cl_platform_id) * num_platforms);
51   clGetPlatformIDs(num_platforms, platforms, NULL);
52   debug(D_LOG, "Found %d platforms.", num_platforms);
53   cl_platform_id chosen_platform=NULL;
54
55    for(i=0; i<num_platforms; i++){
56      char *platform_vendor;
57      size_t param_value_size_ret;
58
59      clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, 0, NULL, &param_value_size_ret );
60      platform_vendor = (char *)malloc(param_value_size_ret);
61      clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, param_value_size_ret, platform_vendor, NULL );
62
63      debug(D_LOG, "platform_vendor: %s",platform_vendor);
64      if( strcmp(platform_vendor, "ocl-icd ICD test") == 0)
65        chosen_platform = platforms[i];
66      free(platform_vendor);
67   }
68   if( chosen_platform == NULL ) {
69     fprintf(stderr,"Error LIG platform not found!\n");
70     return -1;
71   }
72
73   printf("---\n");
74   fflush(NULL);
75   call_all_OpenCL_functions(chosen_platform);
76   return 0;
77 }