What's wrong
I'm trying to include some C code in my .cl
code to call from the kernel.
As far as I can tell, the compiler can find the .h
files fine, but fails to include the implementation .c
file.
I'm using C# with OpenCL.NetCore
source code is located in a folder named cl
Program(s) are built with this:
Cl.BuildProgram(program, 1, new[] { device }, "-I cl", null, IntPtr.Zero);
Error reads as:
ptxas fatal: Unresolved extern function 'iTest'
Code
Kernel code
#include "test.h"
__kernel void sampleKernel(
__global const int *a,
__global const int *b,
__global int *c
) {
int gid = get_global_id(0);
c[gid] = iTest(a[gid] * b[gid]);
}
test.h
#pragma once
int iTest(int x);
test.c
#include "test.h"
int iTest(int x) {
return x + 1000000;
}
If I add #include "test.c"
to the end of test.h the code runs as expected so it can reach the file at least, but I'd like to understand why the compiler isn't including the implementation on it's own, or at least whatever is the correct/best way to do this. Did I forget something really basic?