Skip to content

Commit

Permalink
Simplify testing function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Dec 15, 2023
1 parent 3771800 commit 1ad5308
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/kbmod/search/kernel_testing_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,19 @@ extern "C" void SigmaGFilteredIndicesCU(float *values, int num_values, float sgl
* Return the list of indices from the values array such that those elements
* pass the sigmaG filtering defined by percentiles [sgl0, sgl1] with coefficient
* sigma_g_coeff and a multiplicative factor of width.
*
* The vector values is passed by value to create a local copy which will be modified by
* SigmaGFilteredIndicesCU.
*/
std::vector<int> sigmaGFilteredIndices(const std::vector<float> &values, float sgl0, float sgl1,
float sigma_g_coeff, float width) {
// Bounds check the percentile values.
assert(sgl0 > 0.0);
assert(sgl1 < 1.0);

// Allocate space for the input and result.
const int num_values = values.size();
float values_arr[num_values];
int idx_array[num_values];
for (int i = 0; i < num_values; ++i) {
values_arr[i] = values[i];
}

std::vector<int> sigmaGFilteredIndices(std::vector<float> values, float sgl0, float sgl1, float sigma_g_coeff,
float width) {
int num_values = values.size();
std::vector<int> idx_array(num_values, 0);
int min_keep_idx = 0;
int max_keep_idx = num_values - 1;

#ifdef HAVE_CUDA
SigmaGFilteredIndicesCU(values_arr, num_values, sgl0, sgl1, sigma_g_coeff, width, idx_array,
SigmaGFilteredIndicesCU(values.data(), num_values, sgl0, sgl1, sigma_g_coeff, width, idx_array.data(),
&min_keep_idx, &max_keep_idx);
#else
throw std::runtime_error("Non-GPU SigmaGFilteredIndicesCU is not implemented.");
Expand Down

0 comments on commit 1ad5308

Please sign in to comment.