Skip to content

Commit

Permalink
fix CPU calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
xspanger3770 committed Apr 18, 2024
1 parent a1bb202 commit bf0e4ab
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String[] args) throws Exception {

Settings.hypocenterDetectionResolution = 40.0;
Settings.pWaveInaccuracyThreshold = 4000.0;
Settings.hypocenterDetectionResolutionGPU = 20.0;
Settings.hypocenterDetectionResolutionGPU = 0.0;
Settings.parallelHypocenterLocations = true;
long a = System.currentTimeMillis();

Expand Down Expand Up @@ -67,27 +67,27 @@ public static void main(String[] args) throws Exception {
}


public static void calibrateResolution(ProgressUpdateFunction progressUpdateFunction, JSlider slider, boolean cpu) {
public static void calibrateResolution(ProgressUpdateFunction progressUpdateFunction, JSlider slider, boolean cpuOnly) {
double resolution = 0.0;
long lastTime;
int seed = 6543;
int failed = 0;

long targetTime = HypocsSettings.getOrDefaultInt("calibrateTargetTime", 400);

while (failed < 5 && resolution <= (cpu ? 160 : 1000)) {
if (cpu) {
while (failed < 5 && resolution <= (cpuOnly ? 160 : 1000)) {
if (cpuOnly) {
Settings.hypocenterDetectionResolution = resolution;
} else {
Settings.hypocenterDetectionResolutionGPU = resolution;
}

lastTime = measureTest(seed++, 60, cpu);
lastTime = measureTest(seed++, 60, cpuOnly);
if (lastTime > targetTime) {
failed++;
} else {
failed = 0;
resolution += cpu ? 2.0 : 5.0;
resolution += cpuOnly ? 2.0 : 5.0;
}
if (progressUpdateFunction != null) {
progressUpdateFunction.update("Calibrating: Resolution %.2f took %d / %d ms".formatted(
Expand All @@ -107,13 +107,13 @@ public static void calibrateResolution(ProgressUpdateFunction progressUpdateFunc
Settings.save();
}

public static long measureTest(long seed, int stations, boolean cpu) {
public static long measureTest(long seed, int stations, boolean cpuOnly) {
long a = System.currentTimeMillis();
runTest(seed, stations, cpu);
runTest(seed, stations, cpuOnly);
return System.currentTimeMillis() - a;
}

public static double runTest(long seed, int stations, boolean cpu) {
public static double runTest(long seed, int stations, boolean cpuOnly) {
EarthquakeAnalysis earthquakeAnalysis = new EarthquakeAnalysis();
earthquakeAnalysis.testing = true;

Expand Down Expand Up @@ -155,7 +155,7 @@ public static double runTest(long seed, int stations, boolean cpu) {

cluster.calculateRoot(fakeStations);

HypocenterFinderSettings finderSettings = EarthquakeAnalysis.createSettings(true);
HypocenterFinderSettings finderSettings = EarthquakeAnalysis.createSettings(!cpuOnly);

PreliminaryHypocenter result = earthquakeAnalysis.runHypocenterFinder(pickedEvents, cluster, finderSettings, true);

Expand Down

0 comments on commit bf0e4ab

Please sign in to comment.