this.executions = new ExecutionState[GPUHardwareType.EXECUTION_TOTAL];
boolean hasBitAlign;
boolean hasBFI_INT = false;
CLProgram program;
this.device = device;
PointerBuffer properties = BufferUtils.createPointerBuffer(3);
properties.put(CL10.CL_CONTEXT_PLATFORM).put(platform.getPointer()).put(0).flip();
int err = 0;
int deviceCU = device.getInfoInt(CL10.CL_DEVICE_MAX_COMPUTE_UNITS);
long deviceWorkSize;
int forceWorkSize = diabloMiner.getGPUForceWorkSize();
if(forceWorkSize > 0)
deviceWorkSize = forceWorkSize;
else if(LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX)
deviceWorkSize = device.getInfoSize(CL10.CL_DEVICE_MAX_WORK_GROUP_SIZE);
else
deviceWorkSize = 64;
context = CL10.clCreateContext(properties, device, new CLContextCallback() {
protected void handleMessage(String errinfo, ByteBuffer private_info) {
diabloMiner.error(errinfo);
}
}, null);
ByteBuffer extb = BufferUtils.createByteBuffer(1024);
CL10.clGetDeviceInfo(device, CL10.CL_DEVICE_EXTENSIONS, extb, null);
byte[] exta = new byte[1024];
extb.get(exta);
if(new String(exta).contains("cl_amd_media_ops"))
hasBitAlign = true;
else
hasBitAlign = false;
if(hasBitAlign) {
if(deviceName.contains("Cedar") || deviceName.contains("Redwood") || deviceName.contains("Juniper") || deviceName.contains("Cypress") || deviceName.contains("Hemlock") || deviceName.contains("Caicos") || deviceName.contains("Turks") || deviceName.contains("Barts") || deviceName.contains("Cayman") || deviceName.contains("Antilles") || deviceName.contains("Palm") || deviceName.contains("Sumo") || deviceName.contains("Wrestler") || deviceName.contains("WinterPark") || deviceName.contains("BeaverCreek"))
hasBFI_INT = true;
}
// String compileOptions =
// "-save-temps="+(device.getInfoString(CL10.CL_DEVICE_NAME).trim());
String compileOptions = "";
compileOptions += " -D WORKSIZE=" + deviceWorkSize;
if(hasBitAlign)
compileOptions += " -D BITALIGN";
if(hasBFI_INT)
compileOptions += " -D BFIINT";
program = CL10.clCreateProgramWithSource(context, hardwareType.getSource(), null);
err = CL10.clBuildProgram(program, device, compileOptions, null);
if(err != CL10.CL_SUCCESS) {
ByteBuffer logBuffer = BufferUtils.createByteBuffer(1024);
byte[] log = new byte[1024];
CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, logBuffer, null);
logBuffer.get(log);
System.out.println(new String(log));
throw new DiabloMinerFatalException(diabloMiner, "Failed to build program on " + deviceName);
}
if(hasBFI_INT) {
diabloMiner.info("BFI_INT patching enabled, disabling hardware check errors");
hwcheck = false;
int binarySize = (int) program.getInfoSizeArray(CL10.CL_PROGRAM_BINARY_SIZES)[0];
ByteBuffer binary = BufferUtils.createByteBuffer(binarySize);
program.getInfoBinaries(binary);
for(int pos = 0; pos < binarySize - 4; pos++) {
if((long) (0xFFFFFFFF & binary.getInt(pos)) == 0x464C457FL && (long) (0xFFFFFFFF & binary.getInt(pos + 4)) == 0x64010101L) {
boolean firstText = true;