Skip to content

Commit

Permalink
cuda improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xspanger3770 committed Apr 18, 2024
1 parent 94aef3f commit c785d95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions GQHypocenterSearch/src/hypocenter_search.cu
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ __global__ void evaluate_hypocenter(float *results,
return;
}

int j = blockIdx.y % station_count;
int j = (blockIdx.y + point_index) % station_count;
float final_origin = 0.0f;

// trick with changing station that is being used for origin calculation
Expand All @@ -239,16 +239,14 @@ __global__ void evaluate_hypocenter(float *results,
float err = 0.0f;
float correct = 0.0f;

float k = 1.0f / p_wave_threshold;

for (int i = 0; i < station_count; i++) {
float ang_dist = station_distances[point_index + i * points];
float s_pwave = s_stations[i];
float expected_travel_time = travel_table_interpolate(s_travel_table, ang_dist);
float predicted_origin = s_pwave - expected_travel_time;

float _err = fabsf(predicted_origin - final_origin);
correct += k * fmaxf(0.0f, p_wave_threshold - _err);
correct += fmaxf(0.0f, p_wave_threshold - _err); // divide by p_wave_threshold at the end! ! actually we dont have to
err += _err;
}

Expand Down
8 changes: 4 additions & 4 deletions GQHypocenterSearch/src/travel_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ float p_wave_interpolate(float ang, float depth) {
float row = (depth / table_max_depth) * (table_rows - 1.0);
float column = (ang / MAX_ANG) * (table_columns - 1.0);

int row_floor = floor(row);
int col_floor = floor(column);
int row_ceil = fmin(table_rows - 1, row_floor + 1);
int col_ceil = fmin(table_columns - 1, col_floor + 1);
int row_floor = fmin(table_rows - 2, floor(row));
int col_floor = fmin(table_columns - 2, floor(column));
int row_ceil = row_floor + 1;
int col_ceil = col_floor;

float row_frac = row - row_floor;
float col_frac = column - col_floor;
Expand Down

0 comments on commit c785d95

Please sign in to comment.