Skip to content

Commit

Permalink
fix mdr l2 error control
Browse files Browse the repository at this point in the history
  • Loading branch information
JieyangChen7 committed Nov 15, 2024
1 parent 523203f commit 88e350d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 35 deletions.
33 changes: 17 additions & 16 deletions include/mgard-x/MDR-X/BitplaneEncoder/GroupedBPEncoderGPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class GroupedEncoderFunctor : public Functor<DeviceType> {
} else if (BinaryType == NEGABINARY) {
mantissa = data - fps_data;
}
uint64_t mask = (1 << bitplane_idx) - 1;
T_fp mask = ((T_fp)1 << bitplane_idx) - 1;
T_error diff = 0;
if (BinaryType == BINARY) {
diff = (T_error)(fp_data & mask) + mantissa;
Expand Down Expand Up @@ -367,8 +367,8 @@ class GroupedEncoderFunctor : public Functor<DeviceType> {
// }

// for (int i = 0; i < num_bitplanes + 1; i++) {
// printf("error %d/%d: ", i, num_bitplanes + 1);
// printf (" %f ", sm_errors[i]);
// printf("error %d/%llu: ", i, num_bitplanes + 1);
// printf (" %.12f ", sm_errors[i]);
// printf("\n");
// }
// clang-format on
Expand Down Expand Up @@ -680,19 +680,20 @@ class GroupedDecoderFunctor : public Functor<DeviceType> {

MGARDX_EXEC void Operation4() {

if (debug) {
// for (int i = 0; i < num_bitplanes; i++) {
// printf("decode bitpane[%d]: ", i);
// for (int j = 0; j < num_batches_per_TB; j++) {
// printf(" %u ", sm_bitplanes[j*num_bitplanes+i]);
// // for (int k = 0; k < B; k++) {
// // printf("%u", (sm_bitplanes[j*B+i] >> B-1-k) & 1u);
// // }
// }
// printf("\n");
// }
// printf("\n");
}
// if (debug) {
// for (int i = 0; i < num_bitplanes; i++) {
// printf("decode bitpane[%d]: ", i);
// for (int j = 0; j < num_batches_per_TB; j++) {
// printf(" %u ", sm_bitplanes[j*num_bitplanes+i]);
// for (int k = 0; k < sizeof(T_bitplane)*8; k++) {
// printf("%u", (sm_bitplanes[j*num_bitplanes+i] >>
// sizeof(T_bitplane)*8-1-k) & 1u);
// }
// }
// printf("\n");
// }
// printf("\n");
// }

// if (debug) {
// printf("sm_signs: ");
Expand Down
9 changes: 6 additions & 3 deletions include/mgard-x/MDR-X/Reconstructor/ComposedReconstructor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ class ComposedReconstructor
level_errors = level_abs_errors;

MaxErrorEstimatorOB<T_data> estimator(D);
SignExcludeGreedyBasedSizeInterpreter interpreter(estimator);
// SignExcludeGreedyBasedSizeInterpreter interpreter(estimator);
GreedyBasedSizeInterpreter interpreter(estimator);
// RoundRobinSizeInterpreter interpreter(estimator);
// InorderSizeInterpreter interpreter(estimator);
retrieve_sizes = interpreter.interpret_retrieve_size(
Expand All @@ -154,10 +155,12 @@ class ComposedReconstructor
SNormErrorEstimator<T_data> estimator(D, hierarchy->l_target(),
mdr_metadata.requested_s);
// InorderSizeInterpreter interpreter(estimator);
SignExcludeGreedyBasedSizeInterpreter interpreter(estimator);
GreedyBasedSizeInterpreter interpreter(estimator);
// SignExcludeGreedyBasedSizeInterpreter interpreter(estimator);
// NegaBinaryGreedyBasedSizeInterpreter interpreter(estimator);
retrieve_sizes = interpreter.interpret_retrieve_size(
mdr_metadata.level_sizes, level_errors, mdr_metadata.requested_tol,
mdr_metadata.level_sizes, level_errors,
std::pow(mdr_metadata.requested_tol, 2),
mdr_metadata.requested_level_num_bitplanes);
}
timer.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class GreedyBasedSizeInterpreter : public concepts::SizeInterpreterInterface {
CompareUnitErrorGain>
heap;
for (int i = 0; i < num_levels; i++) {
double error_gain = error_estimator.estimate_error_gain(
accumulated_error, level_errors[i][index[i]],
level_errors[i][index[i] + 1], i);
heap.push(UnitErrorGain(error_gain / level_sizes[i][index[i]], i));
if (index[i] < level_sizes[i].size()) {
double error_gain = error_estimator.estimate_error_gain(
accumulated_error, level_errors[i][index[i]],
level_errors[i][index[i] + 1], i);
heap.push(UnitErrorGain(error_gain / level_sizes[i][index[i]], i));
}
}

bool tolerance_met = false;
Expand All @@ -60,17 +62,15 @@ class GreedyBasedSizeInterpreter : public concepts::SizeInterpreterInterface {
tolerance_met = true;
}
index[i]++;
if (index[i] != level_sizes[i].size()) {
if (index[i] < level_sizes[i].size()) {
double error_gain = error_estimator.estimate_error_gain(
accumulated_error, level_errors[i][index[i]],
level_errors[i][index[i] + 1], i);
heap.push(UnitErrorGain(error_gain / level_sizes[i][index[i]], i));
}
std::cout << i;
}
std::cout << std::endl;
std::cout << "Requested tolerance = " << tolerance
<< ", estimated error = " << accumulated_error << std::endl;
// std::cout << "Requested tolerance = " << tolerance
// << ", estimated error = " << accumulated_error << std::endl;
return retrieve_sizes;
}
void print() const {
Expand Down
10 changes: 5 additions & 5 deletions include/mgard-x/RuntimeX/DataStructures/MDRMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class MDRMetadata {
loaded_level_num_bitplanes[level_idx],
requested_level_num_bitplanes[level_idx]);
}
printf("level_num_elems: ");
for (int level_idx = 0; level_idx < num_levels; level_idx++) {
printf("%llu ", level_num_elems[level_idx]);
}
printf("\n");
// printf("level_num_elems: ");
// for (int level_idx = 0; level_idx < num_levels; level_idx++) {
// printf("%llu ", level_num_elems[level_idx]);
// }
// printf("\n");
}

void DoneLoadingBitplans() {
Expand Down
4 changes: 2 additions & 2 deletions src/mgard-x/Executables/mdr-x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void print_usage_message(std::string error) {
\t\t -o / --output <path to reconstructed data file>\n\
\t\t (optional) -g / --orginal <path to original data file for error calculation> (optinal)\n\
\t\t -e / --error-bound <float>: error bound\n\
\t\t -me / --multi-error-bounds <num errors> <float> <float>..: multiple error bounds\n\
\t\t -me / --multi-error-bounds <num of error bounds> <float> <float>..: multiple error bounds\n\
\t\t -s / --smoothness <float>: smoothness parameter\n\
\t\t -d <auto|serial|cuda|hip>: device type\n\
\t\t (optional) -v / --verbose <0|1|2|3> 0: error; 1: error+info; 2: error+timing; 3: all\n");
Expand Down Expand Up @@ -502,7 +502,7 @@ bool try_reconstruction(int argc, char *argv[]) {
if (has_arg(argc, argv, "-g", "--orignal")) {
original_file =
get_arg<std::string>(argc, argv, "Original data", "-g", "--orignal");
enum mgard_x::data_type dtype = get_data_type(argc, argv);
dtype = get_data_type(argc, argv);
shape = get_args<mgard_x::SIZE>(argc, argv, "Dimensions", "-dim",
"--dimension");
}
Expand Down

0 comments on commit 88e350d

Please sign in to comment.