[SPIRV] Building a LevelZero from a SPIRVResult
package uk.ac.manchester.tornado.drivers.spirv;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.FileChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
import uk.ac.manchester.tornado.api.exceptions.TornadoBailoutRuntimeException;
import uk.ac.manchester.tornado.drivers.spirv.graal.SPIRVInstalledCode;
import uk.ac.manchester.tornado.drivers.spirv.graal.SPIRVLevelZeroInstalledCode;
@@ -17,15 +27,6 @@ import uk.ac.manchester.tornado.drivers.spirv.levelzero.ZeResult;
import uk.ac.manchester.tornado.drivers.spirv.levelzero.utils.LevelZeroUtils;
import uk.ac.manchester.tornado.runtime.tasks.meta.TaskMetaData;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
public class SPIRVLevelZeroCodeCache extends SPIRVCodeCache {
public SPIRVLevelZeroCodeCache(SPIRVDeviceContext deviceContext) {
@@ -42,16 +43,16 @@ public class SPIRVLevelZeroCodeCache extends SPIRVCodeCache {
} catch (IOException e) {
System.err.println("IO exception: " + e.getMessage());
}
-
}
@Override
public SPIRVInstalledCode installSPIRVBinary(TaskMetaData meta, String id, String entryPoint, byte[] code) {
- System.out.println("Installing SPIRV Binary from byte[]");
- ByteBuffer buffer = ByteBuffer.wrap(code);
+ ByteBuffer buffer = ByteBuffer.allocate(code.length);
+ buffer.order(ByteOrder.LITTLE_ENDIAN);
+ buffer.put(code);
try {
Path path = Files.createTempDirectory("tornadoVM-spirv");
- String file = path.toAbsolutePath().toString() + id + entryPoint + ".spv";
+ String file = path.toAbsolutePath() + id + entryPoint + ".spv";
System.out.println("SPIRV-File : " + file);
writeBufferToFile(buffer, file);
return installSPIRVBinary(meta, id, entryPoint, file);
