cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

s_c_harish
Journeyman III

Error while including stdio.h

I am unable to include stdio.h in the kernel code.

It shows the following error during compilation of kernel code:

FYI, Visual Studio 2008 was used for development.
Program failed to build.
Device 0 Build Log:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\crt\src\crtdefs.h(36): cat
astrophic error:
          #error directive: ERROR: Use of C runtime library internal header
          file.
  #error ERROR: Use of C runtime library internal header file.
   ^

1 catastrophic error detected in the compilation of "C:\Users\mine\AppData\Local
\Temp\OCL69AB.tmp.cl".
Compilation terminated.
ing=1 -D

I know that the OpenCL version of printf() can be used but I need to use other functions in stdio.h as well.

The kernel code is attached herewith.

#include<stdio.h> __kernel void vecadd(__global int *A, __global int *B, __global int *C, ) { int idx = get_global_id(0); C[idx] = A[idx] - B[idx]; printf("\n%d",C[idx]); }

0 Likes
2 Replies
eugenek
Journeyman III

You can't include stdio.h in the kernel code. It's explicitly prohibited by the OpenCL spec, section 6.8. Most functions from stdio.h are not available on the device, anyway (except the ones like printf, which are explicitly permitted).

0 Likes

 

The library functions defined in the C99 standard headers

assert.h, ctype.h, complex.h, errno.h, fenv.h, float.h, inttypes.h, limits.h, locale.h, setjmp.h, signal.h, stdarg.h, stdio.h, stdlib.h, string.h, tgmath.h, time.h, wchar.h  and wctype.h  are not available.





0 Likes