Hi~
Look at a sample from website
import java.util.Random;
import java.util.Arrays;
import jcuda.Pointer;
import jcuda.Sizeof;
import jcuda.jcudpp.*;
import jcuda.runtime.JCuda;
import jcuda.runtime.cudaMemcpyKind;
public class test {
//@Test
public void test01() throws Exception {
int size=100000;
int[] data1=createRandomIntData(size);
int[] data2=data1.clone();
long start=System.currentTimeMillis();
Arrays.sort(data1);
long use=System.currentTimeMillis()-start;
System.out.printf("Java Quick Sort use %d ms
",use);
start=System.currentTimeMillis();
sort(data2);
use=System.currentTimeMillis()-start;
System.out.printf("In Cuda Sort use %d ms
",use);
boolean same=Arrays.equals(data1,data2);
if(!same) {
System.out.println(“but data not equals”);
}
}
private static int[] createRandomIntData(int n) {
Random random = new Random(0);
int x[] = new int[n];
for (int i = 0; i < n; i++) {
x** = random.nextInt(Integer.MAX_VALUE);
}
return x;
}
private void sort(int array[]) {
int n = array.length;
// Allocate memory on the device
Pointer d_in = new Pointer();
Pointer d_out = new Pointer();
JCuda.cudaMalloc(d_in, n * Sizeof.INT);
JCuda.cudaMalloc(d_out, n * Sizeof.INT);
// Copy the input array from the host to the device
JCuda.cudaMemcpy(d_in, Pointer.to(array), n * Sizeof.INT,
cudaMemcpyKind.cudaMemcpyHostToDevice);
// Create a CUDPPConfiguration for a radix sort of
// an array of ints
CUDPPConfiguration config = new CUDPPConfiguration();
config.algorithm = CUDPPAlgorithm.CUDPP_SORT_RADIX;
config.datatype = CUDPPDatatype.CUDPP_INT;
config.op = CUDPPOperator.CUDPP_ADD;
long start=System.currentTimeMillis();
// Create a CUDPPHandle for the sort operation
CUDPPHandle handle = new CUDPPHandle();
JCudpp.cudppPlan(handle, config, n, 1, 0);
// Execute the sort operation
JCudpp.cudppSort(handle, d_out, d_in, n, 0);
System.out.printf("Core use %d ms
",System.currentTimeMillis()-start);
// Copy the result from the device to the host
JCuda.cudaMemcpy(Pointer.to(array), d_out, n * Sizeof.INT,
cudaMemcpyKind.cudaMemcpyDeviceToHost);
// Clean up
JCudpp.cudppDestroyPlan(handle);
JCuda.cudaFree(d_in);
JCuda.cudaFree(d_out);
}
public static void main(String[] args) throws Exception {
new test().test01();
}
}
error message
Java Quick Sort use 16 ms
Error while loading native library with base name “JCudpp”
Operating system name: Windows XP
Architecture : x86
Architecture bit size: 32
Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load native library
at jcuda.LibUtils.loadLibrary(LibUtils.java:79)
at jcuda.jcudpp.JCudpp.assertInit(JCudpp.java:175)
at jcuda.jcudpp.JCudpp.cudppPlan(JCudpp.java:214)
at test.sort(test.java:63)
at test.test01(test.java:22)
at test.main(test.java:81)
I put the .java document in the same directory with your sample~:(