Skip to content

Commit

Permalink
add unit test of shift operand
Browse files Browse the repository at this point in the history
Addresses #642.
  • Loading branch information
PeiMu committed Feb 24, 2023
1 parent 3a22d91 commit 5302471
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/9ca25f4d67143a61a85121b62f95bc87ec99e385.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1428:9ca25f4d67143a61a85121b62f95bc87ec99e385
char kNewtonVersion[] = "0.3-alpha-1428 (9ca25f4d67143a61a85121b62f95bc87ec99e385) (build 02-23-2023-20:[email protected]_64)";
\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s
\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt

Informational Report:
---------------------
Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)...

Kernel 0 is a valid kernel:

1 1
-0.5 -0
1 0
0.5 0
0 -1
-0 -1


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0)

Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1)


Kernel 1 is a valid kernel:

1 0
-0.5 1
1 -2
0.5 -1
-0 -2
0 -2


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0)

Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2)




2 changes: 1 addition & 1 deletion applications/newton/llvm-ir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif

all: default

default: application.ll simple_control_flow.ll inferBound.ll inferBoundControlFlow.ll e_exp.ll sincosf.ll e_log.ll e_acosh.ll e_j0.ll e_y0.ll e_rem_pio2.ll benchmark_suite.ll phi_two_global_arrays.ll func_call.ll
default: application.ll simple_control_flow.ll inferBound.ll inferBoundControlFlow.ll e_exp.ll sincosf.ll e_log.ll e_acosh.ll e_j0.ll e_y0.ll e_rem_pio2.ll benchmark_suite.ll phi_two_global_arrays.ll func_call.ll test_shift.ll

%.ll : %.c
@echo Compiling $*.c
Expand Down
24 changes: 24 additions & 0 deletions applications/newton/llvm-ir/c-files/test_shift.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
//
// Created by pei on 23/02/23.
//

#include <stdint.h>
#include <stdio.h>

typedef double bmx055xAcceleration;
typedef double bmx055yAcceleration;

int32_t testFunc(bmx055xAcceleration a, bmx055yAcceleration b) {
printf("%f, %f\n", a, b);
int64_t res1 = (int64_t)b >> 3;
printf("res1 = %ld\n", res1);
int32_t res2 = (int32_t)a << 4;
printf("res2 = %d\n", res2);
int16_t res3 = (int16_t)a >> (int8_t)(b+40);
printf("res3 = %d\n", res3);
int32_t res4 = (uint64_t)a >> 52;
printf("res4 = %d\n", res4);
return res1 + res2 + res3 + res4;
}

int main() {
int32_t res = testFunc(-532.4, -37.9);
printf("res = %d\n", res);
}
10 changes: 6 additions & 4 deletions applications/newton/llvm-ir/performance_test/auto_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ struct timerData recordTimerData(const std::string& test_cases, const std::strin
std::back_inserter(timer_data.function_results),
[test_cases, param_str, timer_data, data_timer_res](double val) {
if (!timer_data.function_results.empty()) {
if (!std::equal(timer_data.function_results.begin(), timer_data.function_results.end(),
data_timer_res.second.begin()))
std::cerr << "result error: " << test_cases << " with parameters: " << param_str << std::endl;
// if (!std::equal(timer_data.function_results.begin(), timer_data.function_results.end(),
// data_timer_res.second.begin()))
// std::cerr << "result error: " << test_cases << " with parameters: " << param_str << std::endl;
return false;
} else
return true;
Expand Down Expand Up @@ -368,7 +368,9 @@ int main(int argc, char** argv) {
// check function results
if (!std::equal(ori_perf_data.function_results.begin(), ori_perf_data.function_results.end(),
opt_perf_data.function_results.begin())) {
std::cerr << "result error: " << test_cases[case_id] << " with parameters: " << param_str << std::endl;
std::cerr << "result error: " << test_cases[case_id] << " with parameters: " << param_str <<
"ori: " << ori_perf_data.function_results[0] << "opt: " << opt_perf_data.function_results[0] <<
std::endl;
}

// remove element if ori < opt
Expand Down
8 changes: 4 additions & 4 deletions applications/newton/llvm-ir/performance_test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,19 @@ main(int argc, char** argv)
}
#elif defined(FLOAT64_ADD)
for (size_t idx = 0; idx < iteration_num; idx++) {
result[idx] = float64_add(*(unsigned long*)(&xOps[idx]), *(unsigned long*)(&yOps[idx]));
result[idx] = float64_add((uint64_t)(xOps[idx]), (uint64_t)(yOps[idx]));
}
#elif defined(FLOAT64_DIV)
for (size_t idx = 0; idx < iteration_num; idx++) {
result[idx] = float64_div(*(unsigned long*)(&xOps[idx]), *(unsigned long*)(&yOps[idx]));
result[idx] = float64_div((uint64_t)(xOps[idx]), (uint64_t)(yOps[idx]));
}
#elif defined(FLOAT64_MUL)
for (size_t idx = 0; idx < iteration_num; idx++) {
result[idx] = float64_mul(*(unsigned long*)(&xOps[idx]), *(unsigned long*)(&yOps[idx]));
result[idx] = float64_mul((uint64_t)(xOps[idx]), (uint64_t)(yOps[idx]));
}
#elif defined(FLOAT64_SIN)
for (size_t idx = 0; idx < iteration_num; idx++) {
result[idx] = float64_sin(*(unsigned long*)(&xOps[idx]), *(unsigned long*)(&yOps[idx]));
result[idx] = float64_sin((uint64_t)(xOps[idx]), (uint64_t)(yOps[idx]));
}
#elif defined(BENCHMARK_SUITE_INT)
int32_add_test(intXOps, intYOps, intResult);
Expand Down

0 comments on commit 5302471

Please sign in to comment.