mirror of https://github.com/jlizier/jidt
Merge pull request #73 from pmediano/master
Minor updates to GPU tests and examples following v1.5 release.
This commit is contained in:
commit
2ba27f30ac
|
@ -67,9 +67,10 @@ public class Example10GPUBenchmark {
|
||||||
miCalc.setProperty("k", "4");
|
miCalc.setProperty("k", "4");
|
||||||
miCalc.initialise(src[0].length, tgt[0].length);
|
miCalc.initialise(src[0].length, tgt[0].length);
|
||||||
miCalc.setObservations(src, tgt);
|
miCalc.setObservations(src, tgt);
|
||||||
|
int nb_surrogates = 150;
|
||||||
double[] timeAndValue = new double[2];
|
double[] timeAndValue = new double[2];
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
timeAndValue[1] = miCalc.computeAverageLocalOfObservations();
|
timeAndValue[1] = miCalc.computeSignificance(nb_surrogates).actualValue;
|
||||||
timeAndValue[0] = (System.nanoTime() - startTime)/1000000.0;
|
timeAndValue[0] = (System.nanoTime() - startTime)/1000000.0;
|
||||||
return timeAndValue;
|
return timeAndValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,9 +717,10 @@ public abstract class MutualInfoCalculatorMultiVariateKraskov
|
||||||
System.load(gpuLibraryPath);
|
System.load(gpuLibraryPath);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
String errmsg = "GPU library not found. To compile GPU code set the enablegpu flag to true in build.xml";
|
String errmsg = "GPU library not found. To compile GPU code set the enablegpu flag to true in build.xml, or run `ant gpu jar`.";
|
||||||
|
errmsg += "\nFor more information see the JIDT GPU wiki page: https://github.com/jlizier/jidt/wiki/GPU";
|
||||||
if (gpuLibraryPath.length() > 0) {
|
if (gpuLibraryPath.length() > 0) {
|
||||||
errmsg += "\nGPU library was not found in the path provided. Provide full path including library file name.";
|
errmsg += "\n\nGPU library was not found in the path provided. Provide full path including library file name.";
|
||||||
errmsg += "\nExample: /home/johndoe/myfolder/libKraskov.so";
|
errmsg += "\nExample: /home/johndoe/myfolder/libKraskov.so";
|
||||||
}
|
}
|
||||||
throw new Exception(errmsg);
|
throw new Exception(errmsg);
|
||||||
|
|
|
@ -86,14 +86,14 @@ public class GPUPerformanceTester extends TestCase {
|
||||||
startTime = Calendar.getInstance().getTimeInMillis();
|
startTime = Calendar.getInstance().getTimeInMillis();
|
||||||
miCalc.initialise(1,1);
|
miCalc.initialise(1,1);
|
||||||
miCalc.setObservations(source, dest);
|
miCalc.setObservations(source, dest);
|
||||||
cpu_val = miCalc.computeSignificance(nb_surrogates).getMeanOfDistribution();
|
cpu_val = miCalc.computeSignificance(nb_surrogates).actualValue;
|
||||||
cpu_duration = Calendar.getInstance().getTimeInMillis() - startTime;
|
cpu_duration = Calendar.getInstance().getTimeInMillis() - startTime;
|
||||||
|
|
||||||
miCalc.setProperty("USE_GPU", "true");
|
miCalc.setProperty("USE_GPU", "true");
|
||||||
miCalc.initialise(1,1);
|
miCalc.initialise(1,1);
|
||||||
startTime = Calendar.getInstance().getTimeInMillis();
|
startTime = Calendar.getInstance().getTimeInMillis();
|
||||||
miCalc.setObservations(source, dest);
|
miCalc.setObservations(source, dest);
|
||||||
gpu_val = miCalc.computeSignificance(nb_surrogates).getMeanOfDistribution();
|
gpu_val = miCalc.computeSignificance(nb_surrogates).actualValue;
|
||||||
gpu_duration = Calendar.getInstance().getTimeInMillis() - startTime;
|
gpu_duration = Calendar.getInstance().getTimeInMillis() - startTime;
|
||||||
|
|
||||||
assertEquals(cpu_val, gpu_val, 0.0001);
|
assertEquals(cpu_val, gpu_val, 0.0001);
|
||||||
|
@ -124,12 +124,12 @@ public class GPUPerformanceTester extends TestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeSteps = 10000;
|
int timeSteps = 1000;
|
||||||
RandomGenerator rg = new RandomGenerator();
|
RandomGenerator rg = new RandomGenerator();
|
||||||
double[] source = rg.generateNormalData(timeSteps, 0, 1);
|
double[] source = rg.generateNormalData(timeSteps, 0, 1);
|
||||||
double[] dest = rg.generateNormalData(timeSteps, 0, 1);
|
double[] dest = rg.generateNormalData(timeSteps, 0, 1);
|
||||||
|
|
||||||
compareGPUPerformance(source, dest, "Random low-dimensional data");
|
compareGPUPerformanceSurrogates(source, dest, 150, "Random low-dimensional data");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue