[OpenCL] support for SPIRV kernel loading for FPGAs
@@ -608,12 +608,18 @@ public class OCLCodeCache {
}
OCLProgram program;
+ boolean isSPIRVBinary = false;
OCLBuildStatus status = CL_BUILD_SUCCESS;
if (shouldReuseProgramObject(entryPoint)) {
program = cache.get(LOOKUP_BUFFER_KERNEL_NAME).getProgram();
} else {
long beforeLoad = (Tornado.TIME_IN_NANOSECONDS) ? System.nanoTime() : System.currentTimeMillis();
+ isSPIRVBinary = isInputSourceSPIRVBinary(binary);
+ if (isSPIRVBinary) {
+ program = deviceContext.createProgramWithIL(binary, new long[] { binary.length });
+ } else {
program = deviceContext.createProgramWithBinary(binary, new long[] { binary.length });
+ }
long afterLoad = (Tornado.TIME_IN_NANOSECONDS) ? System.nanoTime() : System.currentTimeMillis();
if (PRINT_LOAD_TIME) {
@@ -636,7 +642,7 @@ public class OCLCodeCache {
}
final OCLKernel kernel = (status == CL_BUILD_SUCCESS) ? program.getKernel(entryPoint) : null;
- final OCLInstalledCode code = new OCLInstalledCode(entryPoint, binary, (OCLDeviceContext) deviceContext, program, kernel, false);
+ final OCLInstalledCode code = new OCLInstalledCode(entryPoint, binary, (OCLDeviceContext) deviceContext, program, kernel, isSPIRVBinary);
if (status == CL_BUILD_SUCCESS) {
debug("\tOpenCL Kernel id = 0x%x", kernel.getOclKernelID());
@@ -652,7 +658,7 @@ public class OCLCodeCache {
String childKernelName = pair.entryPoint;
if (!childKernelName.equals(entryPoint)) {
final OCLKernel kernel2 = program.getKernel(childKernelName);
- final OCLInstalledCode code2 = new OCLInstalledCode(entryPoint, binary, (OCLDeviceContext) deviceContext, program, kernel2, false);
+ final OCLInstalledCode code2 = new OCLInstalledCode(entryPoint, binary, (OCLDeviceContext) deviceContext, program, kernel2, isSPIRVBinary);
cache.put(taskScheduleName + "." + pair.taskName + "-" + childKernelName, code2);
}
}
