Bugfix: a NativeLong is 32bits on windows and might be 64bits on unix. A 'JavaLong' is always 64bits.

This commit is contained in:
Laurent Clouet
2014-12-10 15:27:12 +00:00
parent bc9a0e52d0
commit ac2d2227cb
2 changed files with 4 additions and 5 deletions

View File

@@ -20,7 +20,6 @@
package com.sheepit.client.hardware.gpu; package com.sheepit.client.hardware.gpu;
import com.sun.jna.Library; import com.sun.jna.Library;
import com.sun.jna.NativeLong;
public interface CUDA extends Library { public interface CUDA extends Library {
public int cuInit(int flags); public int cuInit(int flags);
@@ -32,5 +31,6 @@ public interface CUDA extends Library {
public int cuDeviceGetName(byte[] name, int len, int dev); public int cuDeviceGetName(byte[] name, int len, int dev);
public int cuDeviceTotalMem(NativeLong bytes[], int dev); // http://en.wikipedia.org/wiki/Java_Native_Access
public int cuDeviceTotalMem(long bytes[], int dev);
} }

View File

@@ -24,7 +24,6 @@ import java.util.List;
import com.sheepit.client.os.OS; import com.sheepit.client.os.OS;
import com.sun.jna.Native; import com.sun.jna.Native;
import com.sun.jna.NativeLong;
public class GPU { public class GPU {
public static List<GPUDevice> devices = null; public static List<GPUDevice> devices = null;
@@ -84,7 +83,7 @@ public class GPU {
continue; continue;
} }
NativeLong[] ram = new NativeLong[1]; long[] ram = new long[1];
result = cudalib.cuDeviceTotalMem(ram, num); result = cudalib.cuDeviceTotalMem(ram, num);
if (result != CUresult.CUDA_SUCCESS) { if (result != CUresult.CUDA_SUCCESS) {
@@ -92,7 +91,7 @@ public class GPU {
return false; return false;
} }
devices.add(new GPUDevice(new String(name).trim(), ram[0].longValue(), "CUDA_" + Integer.toString(num))); devices.add(new GPUDevice(new String(name).trim(), ram[0], "CUDA_" + Integer.toString(num)));
} }
return true; return true;
} }