From 7d8501ea0efce80f2a6b941d3a73dee21bcc4450 Mon Sep 17 00:00:00 2001 From: parth121101 Date: Wed, 10 Jul 2024 22:46:33 +0530 Subject: [PATCH 1/2] tests: add tests for log10 intrinsic --- integration_tests/intrinsics_290.f90 | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 integration_tests/intrinsics_290.f90 diff --git a/integration_tests/intrinsics_290.f90 b/integration_tests/intrinsics_290.f90 new file mode 100644 index 0000000000..b256d35d6a --- /dev/null +++ b/integration_tests/intrinsics_290.f90 @@ -0,0 +1,69 @@ +program intrinsics_290 + use, intrinsic :: iso_fortran_env, only: dp => real64, sp => real32 + real(dp) :: a + real(sp) :: d + integer :: i + real(dp) :: log_runtime_dp(3) = [0.875_dp, 3.367_dp, 2.140_dp] + real(sp) :: log_runtime_sp(3) = [0.875, 3.367, 2.140] + real(dp) :: log_res_dp(3) + real(sp) :: log_res_sp(3) + real(dp) :: expected2_dp(3) = [-5.7991946977686754E-002_dp, 0.52724311638808863_dp, 0.33041377334919086_dp] + real(sp) :: expected2_sp(3) = [-5.79919480E-02_sp, 0.527243137_sp, 0.330413789] + + real(dp), parameter :: res2(3) = log10([0.875_dp, 3.367_dp, 2.140_dp]) + real(sp), parameter :: res2_sp(3) = log10([0.875, 3.367, 2.140]) + + do i = 1, 3 + print *, res2(i) + if (abs(res2(i) - expected2_dp(i)) > 1e-12_dp) error stop + end do + + do i = 1, 3 + print *, res2_sp(i) + if (abs(res2_sp(i) - expected2_sp(i)) > 1e-5) error stop + end do + + log_res_dp = log10(log_runtime_dp) + log_res_sp = log10(log_runtime_sp) + + do i = 1, 3 + print *, log_res_dp(i) + if (abs(log_res_dp(i) - expected2_dp(i)) > 1e-12_dp) error stop + end do + + do i = 1, 3 + print *, log_res_sp(i) + if (abs(log_res_sp(i) - expected2_sp(i)) > 1e-5) error stop + end do + + a = log10(10.92839272_dp) + d = log10(10.92839272) + + print *, a + if (a - 1.03855629331626087e+00_dp > 1e-12_dp) error stop + + print *,log10(10.92839272_dp) + if (log10(10.92839272_dp) - 1.03855629331626087e+00_dp > 1e-12_dp) error stop + + print *, d + if (d - 1.03855634e+00_sp > 1e-5) error stop + + print *, log10(10.92839272) + if (log10(10.92839272) - 1.03855634e+00_sp > 1e-5) error stop + + a = log10(83.728927_dp) + d = log10(31.738222) + + print *, a + if (a - 1.92287552568858744e+00_dp > 1e-12_dp) error stop + + print *,log10(83.728927_dp) + if (log10(83.728927_dp) - 1.92287552568858744e+00_dp > 1e-12_dp) error stop + + print *, d + if (d - 1.50158262e+00_sp > 1e-5) error stop + + print *, log10(31.738222) + if (log10(31.738222) - 1.50158262e+00_sp > 1e-5) error stop + +end program \ No newline at end of file From 4e30526cb0100060dc541bf2dde1503193d3cf53 Mon Sep 17 00:00:00 2001 From: parth121101 Date: Thu, 11 Jul 2024 00:26:48 +0530 Subject: [PATCH 2/2] tests: add tests for gamma intrinsic --- integration_tests/CMakeLists.txt | 2 + integration_tests/intrinsics_290.f90 | 20 ++++---- integration_tests/intrinsics_291.f90 | 69 ++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 integration_tests/intrinsics_291.f90 diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index b93923c4c5..8040feede0 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -852,6 +852,8 @@ RUN(NAME intrinsics_285 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc fortran) # RUN(NAME intrinsics_286 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) # atanh RUN(NAME intrinsics_288 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc fortran) # spread RUN(NAME intrinsics_289 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) # ishftc +RUN(NAME intrinsics_290 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) # log10 +RUN(NAME intrinsics_291 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) # log10 RUN(NAME passing_array_01 LABELS gfortran fortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME passing_array_02 LABELS gfortran fortran llvm llvm_wasm llvm_wasm_emcc) diff --git a/integration_tests/intrinsics_290.f90 b/integration_tests/intrinsics_290.f90 index b256d35d6a..ce8a2cc2d2 100644 --- a/integration_tests/intrinsics_290.f90 +++ b/integration_tests/intrinsics_290.f90 @@ -7,20 +7,20 @@ program intrinsics_290 real(sp) :: log_runtime_sp(3) = [0.875, 3.367, 2.140] real(dp) :: log_res_dp(3) real(sp) :: log_res_sp(3) - real(dp) :: expected2_dp(3) = [-5.7991946977686754E-002_dp, 0.52724311638808863_dp, 0.33041377334919086_dp] - real(sp) :: expected2_sp(3) = [-5.79919480E-02_sp, 0.527243137_sp, 0.330413789] + real(dp) :: expected_dp(3) = [-5.7991946977686754E-002_dp, 0.52724311638808863_dp, 0.33041377334919086_dp] + real(sp) :: expected_sp(3) = [-5.79919480E-02_sp, 0.527243137_sp, 0.330413789] - real(dp), parameter :: res2(3) = log10([0.875_dp, 3.367_dp, 2.140_dp]) - real(sp), parameter :: res2_sp(3) = log10([0.875, 3.367, 2.140]) + real(dp), parameter :: res(3) = log10([0.875_dp, 3.367_dp, 2.140_dp]) + real(sp), parameter :: res_sp(3) = log10([0.875, 3.367, 2.140]) do i = 1, 3 - print *, res2(i) - if (abs(res2(i) - expected2_dp(i)) > 1e-12_dp) error stop + print *, res(i) + if (abs(res(i) - expected_dp(i)) > 1e-12_dp) error stop end do do i = 1, 3 - print *, res2_sp(i) - if (abs(res2_sp(i) - expected2_sp(i)) > 1e-5) error stop + print *, res_sp(i) + if (abs(res_sp(i) - expected_sp(i)) > 1e-5) error stop end do log_res_dp = log10(log_runtime_dp) @@ -28,12 +28,12 @@ program intrinsics_290 do i = 1, 3 print *, log_res_dp(i) - if (abs(log_res_dp(i) - expected2_dp(i)) > 1e-12_dp) error stop + if (abs(log_res_dp(i) - expected_dp(i)) > 1e-12_dp) error stop end do do i = 1, 3 print *, log_res_sp(i) - if (abs(log_res_sp(i) - expected2_sp(i)) > 1e-5) error stop + if (abs(log_res_sp(i) - expected_sp(i)) > 1e-5) error stop end do a = log10(10.92839272_dp) diff --git a/integration_tests/intrinsics_291.f90 b/integration_tests/intrinsics_291.f90 new file mode 100644 index 0000000000..2b811cd52f --- /dev/null +++ b/integration_tests/intrinsics_291.f90 @@ -0,0 +1,69 @@ +program intrinsics_291 + use, intrinsic :: iso_fortran_env, only: dp => real64, sp => real32 + real(dp) :: a + real(sp) :: d + integer :: i + real(dp) :: log_runtime_dp(3) = [0.73925_dp, 4.6272183_dp, 82.1483927190_dp] + real(sp) :: log_runtime_sp(3) = [0.73925, 4.6272183, 8.14839] + real(dp) :: log_res_dp(3) + real(sp) :: log_res_sp(3) + real(dp) :: expected_dp(3) = [1.2399882923281214_dp, 13.907361652217805_dp, 1.1139704077610786E+121_dp] + real(sp) :: expected_sp(3) = [1.23998833, 13.9073610, 6807.07861] + + real(dp), parameter :: res(3) = gamma([0.73925_dp, 4.6272183_dp, 82.1483927190_dp]) + real(sp), parameter :: res_sp(3) = gamma([0.73925, 4.6272183_sp, 8.14839]) + + do i = 1, 3 + print *, res(i) + if (abs(res(i) - expected_dp(i)) > 1e-12_dp) error stop + end do + + do i = 1, 3 + print *, res_sp(i) + if (abs(res_sp(i) - expected_sp(i)) > 1e-5) error stop + end do + + log_res_dp = gamma(log_runtime_dp) + log_res_sp = gamma(log_runtime_sp) + + do i = 1, 3 + print *, log_res_dp(i) + if (abs(log_res_dp(i) - expected_dp(i)) > 1e-12_dp) error stop + end do + + do i = 1, 3 + print *, log_res_sp(i) + if (abs(log_res_sp(i) - expected_sp(i)) > 1e-5) error stop + end do + + a = gamma(21.7282828_dp) + d = gamma(11.63827) + + print *, a + if (a - 2.22349180143608259e+19_dp > 1e-12_dp) error stop + + print *,gamma(21.7282828_dp) + if (gamma(21.7282828_dp) - 2.22349180143608259e+19_dp > 1e-12_dp) error stop + + print *, d + if (d - 16592656.0_sp > 1e-5) error stop + + print *, gamma(11.63827) + if (gamma(11.63827) - 16592656.0_sp > 1e-5) error stop + + a = gamma(61.72812_dp) + d = gamma(7.72818) + + print *, a + if (a - 1.65731626595094650e+83_dp > 1e-12_dp) error stop + + print *,gamma(61.72812_dp) + if (gamma(61.72812_dp) - 1.65731626595094650e+83_dp > 1e-12_dp) error stop + + print *, d + if (d - 2.92850854e+03_sp > 1e-5) error stop + + print *, gamma(7.72818) + if (gamma(7.72818) - 2.92850854e+03_sp > 1e-5) error stop + +end program \ No newline at end of file