deps/include/hpat_sort.h
// Binary search with different starting index
Binary search with different starting index
Binary search with different starting index
static void __hpat_binary_insertionsort_index(int64_t *comp_arr, const size_t start, const size_t size, int64_t ** all_arrs ,const size_t all_arrs_len) {
  for (int64_t ind_start = start; ind_start < size; ind_start++) {
    int64_t ind_curr, elem, pivot;
    if (__hpat_sort_compare(comp_arr[ind_start - 1], comp_arr[ind_start]) <= 0) {
      continue;
    }
    elem = comp_arr[ind_start];
    int64_t temp_x[all_arrs_len];
    for (int k = 0 ; k < all_arrs_len ; k++){
      int64_t * cur_arr = all_arrs[k];
      temp_x[k]= cur_arr[ind_start];
    }
    pivot = __hpat_binary_insertionsort_search(comp_arr, elem, ind_start);
    for (ind_curr = ind_start - 1; ind_curr >= pivot; ind_curr--) {
      comp_arr[ind_curr + 1] = comp_arr[ind_curr];
      for (int k = 0 ; k < all_arrs_len ; k++){
        int64_t * cur_arr = all_arrs[k];
        cur_arr[ind_curr + 1] = cur_arr[ind_curr];
      }
    }
    comp_arr[pivot] = elem;
    for (int k = 0 ; k < all_arrs_len ; k++){
      int64_t * cur_arr = all_arrs[k];
      cur_arr[pivot] = temp_x[k];
    }
  }
}
static void __hpat_binary_insertionsort_index ( int64_t * comp_arr , const size_t start , const size_t size , int64_t * * all_arrs , const size_t all_arrs_len ) { for ( int64_t ind_start = start ; ind_start < size ; ind_start ++ ) { int64_t ind_curr , elem , pivot ; if ( __hpat_sort_compare ( comp_arr [ ind_start - 1 ] , comp_arr [ ind_start ] ) <= 0 ) { continue ; } elem = comp_arr [ ind_start ] ; int64_t temp_x [ all_arrs_len ] ; for ( int k = 0 ; k < all_arrs_len ; k ++ ) { int64_t * cur_arr = all_arrs [ k ] ; temp_x [ k ] = cur_arr [ ind_start ] ; } pivot = __hpat_binary_insertionsort_search ( comp_arr , elem , ind_start ) ; for ( ind_curr = ind_start - 1 ; ind_curr >= pivot ; ind_curr -- ) { comp_arr [ ind_curr + 1 ] = comp_arr [ ind_curr ] ; for ( int k = 0 ; k < all_arrs_len ; k ++ ) { int64_t * cur_arr = all_arrs [ k ] ; cur_arr [ ind_curr + 1 ] = cur_arr [ ind_curr ] ; } } comp_arr [ pivot ] = elem ; for ( int k = 0 ; k < all_arrs_len ; k ++ ) { int64_t * cur_arr = all_arrs [ k ] ; cur_arr [ pivot ] = temp_x [ k ] ; } } }
Binary search with different starting index
Binary search with different starting index
// Already sorted //std::cout << "moving forward" << std::endl;