Skip to content

Commit

Permalink
V3.74 (#405)
Browse files Browse the repository at this point in the history
* Bumping SEMVER to v3.74.1

* removing extraneous function

* adding QSNR to the benchmarking

* adding range reporting for the Scalar type

* adding elastic integer traits to try to disambiguate type_tag (not entirely successful yet)

* compilation fix for gcc and clang

* streamlining elastic binary integer API test

* renaming Adaptive to Elastic

* expanding QSNR experiment to sample across multiple sets

* generalizing qsnr as a service

* adding is_subnormal() attribute method

* specialized posit<16,2> engineering

* redefining nibble markers to be 0-based

* WIP: fast posit<16,2> addition

* restructuring specialized posits test infrastructure

* adding a posit oracle as a separate data type to be used to validate specialized posits

* adding a arithmetic debug test

* Implement specialized posit<16,2> addition (#403)

* rearchitecting the regression test suite to have a universal number system check

* cleaning up include file dependencies

* bug fix in the argument order of ReportBinaryArithmeticError as called in the posit test suite

* WIP: bug fixes for add/sub, not quite there yet

* compilation fix for gcc and clang

* WIP: fast posit<16,2> subtraction checks

* Implement specialized posit<16,2> sub, mul, div (#404)

Div is not working 100% yet

* enabling the regression level 1 again in specialized posit<16,2> while we are RCAing the div on extreme regime values

* bug fix and reporting improvement of posit randoms

* WIP: cleaning up posit<16,1> and posit<16,2>

* adding a math library to the posito oracle so we can use it to compare native implementations

* WIP: building test infrastructure to RCA specialized posit implementations

* WIP: RCAing specialized posit<16,2> divide operator

* adding multiplication tests for specialized posits

* WIP: code hygiene for old posit code

* WIP: redoing the fast posit<16,2> arithmetic operators

* restoring the multiplication operator algorithm

* configuring a regression test for fast posit multiplication

* configuring a regression test for fast posit addition

* test name edit

* configuring a regression test for fast posit division: not enabled yet

* adding a regression suite for fast posit subtraction

* code hygiene for old posit code

* bug fix in fast posit<32,2> that code hygiene activities had introduced

* WIP: fixed bugs in regime and exponent fields for fast posit<16,2>, rounding still buggy

* bug fix of bitnplusone calculation in divround of posit<16,2>

* code hygiene posit<32,2>

* bug fix div operator for fast posit<16,2>

* adding new posit attribute functions: maxprecision_max/min, this is the largest value of Regime 0, and the smallest value of Regime -1

* adding full regression results for reference

---------

Co-authored-by: David Mallasén Quintana <[email protected]>
  • Loading branch information
Ravenwater and davidmallasen authored Jan 3, 2024
1 parent 408b099 commit 7af781f
Show file tree
Hide file tree
Showing 171 changed files with 11,435 additions and 2,278 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(NOT DEFINED UNIVERSAL_VERSION_MAJOR)
set(UNIVERSAL_VERSION_MAJOR 3)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_MINOR)
set(UNIVERSAL_VERSION_MINOR 73)
set(UNIVERSAL_VERSION_MINOR 74)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_PATCH)
set(UNIVERSAL_VERSION_PATCH 1)
Expand Down Expand Up @@ -130,6 +130,7 @@ option(BUILD_NUMBER_AREALS "Set to ON to build static areal tests"
option(BUILD_NUMBER_UNUM1S "Set to ON to build static unum type 1 tests" OFF)
option(BUILD_NUMBER_UNUM2S "Set to ON to build static unum type 2 tests" OFF)
option(BUILD_NUMBER_POSITS "Set to ON to build static unum type 3 posit tests" OFF)
option(BUILD_NUMBER_POSITOS "Set to ON to build static unum type 3 posito tests" OFF)
option(BUILD_NUMBER_VALIDS "Set to ON to build static unum type 3 valid tests" OFF)
option(BUILD_NUMBER_LNS "Set to ON to build static lns tests" OFF)
option(BUILD_NUMBER_DBNS "Set to ON to build static dbns tests" OFF)
Expand Down Expand Up @@ -639,6 +640,7 @@ if(BUILD_NUMBER_STATICS)
set(BUILD_NUMBER_UNUM1S ON)
set(BUILD_NUMBER_UNUM2S ON)
set(BUILD_NUMBER_POSITS ON)
set(BUILD_NUMBER_POSITOS ON)
set(BUILD_NUMBER_VALIDS ON)
set(BUILD_NUMBER_LNS ON)
set(BUILD_NUMBER_DBNS ON)
Expand Down Expand Up @@ -763,6 +765,10 @@ add_subdirectory("static/posit/specialized")
add_subdirectory("static/posit2")
endif(BUILD_NUMBER_POSITS)

if(BUILD_NUMBER_POSITOS)
add_subdirectory("static/posito")
endif(BUILD_NUMBER_POSITOS)

if(BUILD_NUMBER_VALIDS)
add_subdirectory("static/valid")
endif(BUILD_NUMBER_VALIDS)
Expand Down Expand Up @@ -826,6 +832,7 @@ endif(BUILD_MIXEDPRECISION_TENSOR)
if(BUILD_BENCHMARK_ERROR)
add_subdirectory("benchmark/error/sampling")
add_subdirectory("benchmark/error/scaling")
add_subdirectory("benchmark/error/qsnr")
add_subdirectory("benchmark/error/blas")
endif(BUILD_BENCHMARK_ERROR)

Expand Down
2 changes: 1 addition & 1 deletion benchmark/accuracy/quantization/mpdot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ namespace sw {
if constexpr (bCSV) {
std::cout << stats.stddev << ", " << faEquivalency << ", " << stats.mean ;
for (int i = 0; i < 5; ++i) {
std::cout << ", " << stats.quartiles[i];
std::cout << ", " << stats.quantiles.q[i];
}
std::cout << '\n';
}
Expand Down
3 changes: 3 additions & 0 deletions benchmark/error/qsnr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file (GLOB SOURCES "./*.cpp")

compile_all("true" "quantization" "Benchmarks/Error/QSNR" "${SOURCES}")
111 changes: 111 additions & 0 deletions benchmark/error/qsnr/qsnr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// qsnr.cpp: Quantization Signal to Noise ratio for a sampling
//
// Copyright (C) 2022-2023 Stillwater Supercomputing, Inc.
//
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
#include <universal/utility/directives.hpp>

#define INTEGER_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/integer/integer.hpp>
#define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/fixpnt/fixpnt.hpp>
#define CFLOAT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/cfloat/cfloat.hpp>
#define POSIT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/posit/posit.hpp>
#define LNS_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/lns/lns.hpp>

#include <universal/blas/blas.hpp>
#include <universal/quantization/qsnr.hpp>

// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override
#define MANUAL_TESTING 0
// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity
// It is the responsibility of the regression test to organize the tests in a quartile progression.
//#undef REGRESSION_LEVEL_OVERRIDE
#ifndef REGRESSION_LEVEL_OVERRIDE
#undef REGRESSION_LEVEL_1
#undef REGRESSION_LEVEL_2
#undef REGRESSION_LEVEL_3
#undef REGRESSION_LEVEL_4
#define REGRESSION_LEVEL_1 1
#define REGRESSION_LEVEL_2 1
#define REGRESSION_LEVEL_3 1
#define REGRESSION_LEVEL_4 1
#endif

int main()
try {
using namespace sw::universal;

constexpr int nrExperiments = 10;
std::map<std::string, blas::vector<double>> table;
std::vector<std::string> arithmeticTypename = {
"fixpnt<8,2>",
"fixpnt<8,3>",
"fixpnt<8,4>",
"fixpnt<8,5>",
"fp8e2m5",
"fp8e3m4",
"fp8e4m3",
"fp8e5m2",
"posit<8,0>",
"posit<8,1>",
"posit<8,2>",
"posit<8,3>",
"lns<8,2>",
"lns<8,3>",
"lns<8,4>",
"lns<8,5>"
};

for (int i = 0; i < nrExperiments; ++i) {
constexpr unsigned N = 32;
constexpr double mean = 0.0;
constexpr double stddev = 1.0;
auto data = sw::universal::blas::gaussian_random_vector<double>(N, mean, stddev);
table["fixpnt<8,2>"].push_back(qsnr<fixpnt<8, 2>>(data));
table["fixpnt<8,3>"].push_back(qsnr<fixpnt<8, 3>>(data));
table["fixpnt<8,4>"].push_back(qsnr<fixpnt<8, 4>>(data));
table["fixpnt<8,5>"].push_back(qsnr<fixpnt<8, 5>>(data));
table["fp8e2m5"].push_back(qsnr<fp8e2m5>(data));
table["fp8e3m4"].push_back(qsnr<fp8e3m4>(data));
table["fp8e4m3"].push_back(qsnr<fp8e4m3>(data));
table["fp8e5m2"].push_back(qsnr<fp8e5m2>(data));
table["posit<8,0>"].push_back(qsnr<posit<8, 0>>(data));
table["posit<8,1>"].push_back(qsnr<posit<8, 1>>(data));
table["posit<8,2>"].push_back(qsnr<posit<8, 2>>(data));
table["posit<8,3>"].push_back(qsnr<posit<8, 3>>(data));
table["lns<8,2>"].push_back(qsnr<lns<8, 2>>(data));
table["lns<8,3>"].push_back(qsnr<lns<8, 3>>(data));
table["lns<8,4>"].push_back(qsnr<lns<8, 4>>(data));
table["lns<8,5>"].push_back(qsnr<lns<8, 5>>(data));
}

for (auto tag : arithmeticTypename) {
std::cout << std::setw(15) << tag << " : " << blas::quantiles(table[tag]) << '\n';
}

return EXIT_SUCCESS;
}
catch (char const* msg) {
std::cerr << msg << std::endl;
return EXIT_FAILURE;
}
catch (const sw::universal::universal_arithmetic_exception& err) {
std::cerr << "Uncaught arithmetic exception: " << err.what() << std::endl;
return EXIT_FAILURE;
}
catch (const sw::universal::universal_internal_exception& err) {
std::cerr << "Uncaught internal exception: " << err.what() << std::endl;
return EXIT_FAILURE;
}
catch (const std::runtime_error& err) {
std::cerr << "Uncaught runtime exception: " << err.what() << std::endl;
return EXIT_FAILURE;
}
catch (...) {
std::cerr << "Caught unknown exception" << std::endl;
return EXIT_FAILURE;
}
39 changes: 39 additions & 0 deletions benchmark/error/sampling/sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
#include <universal/utility/directives.hpp>

#include <universal/native/ieee754.hpp>

#define INTEGER_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/integer/integer.hpp>
#define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1
Expand Down Expand Up @@ -43,6 +45,21 @@ void SampleError(sw::universal::blas::vector<double>& reals) {
std::cout << "Maximum sampling error : " << maxError << '\n';
}


template<typename Scalar>
void DenormRatio(const sw::universal::blas::vector<double>& reals) {
using std::isdenorm;

using namespace sw::universal;

blas::vector<Scalar> samples(reals);
unsigned denorm{ 0 };
for (auto v : samples) {
if (isdenorm(v)) ++denorm;
}
std::cout << std::setw(80) << type_tag(Scalar()) << " : denorms : " << denorm << " ratio of denorms : " << double(denorm) / size(reals) << '\n';
}

// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override
#define MANUAL_TESTING 0
// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity
Expand All @@ -63,6 +80,7 @@ int main()
try {
using namespace sw::universal;

#if MANUAL_TESTING
auto reals = sw::universal::blas::gaussian_random_vector<double>(10, 0.0, 32.0);

constexpr bool Verbose = false;
Expand All @@ -83,6 +101,27 @@ try {
SampleError< lns<8, 4> >(reals);
SampleError< lns<8, 5> >(reals);


#else

unsigned N = 100000;
double mean{ 0.0 }, stddev{ 1.0 };

auto reals = sw::universal::blas::gaussian_random_vector<double>(N, mean, stddev);

DenormRatio<cfloat<4, 2, uint8_t, true, true, false>>(reals);
DenormRatio<cfloat<6, 2, uint8_t, true, true, false>>(reals);
DenormRatio<cfloat<7, 2, uint8_t, true, true, false>>(reals);
DenormRatio<fp8e2m5>(reals);
DenormRatio<fp8e3m4>(reals);
DenormRatio<fp8e4m3>(reals);
DenormRatio<half>(reals);
DenormRatio<float>(reals);
DenormRatio<double>(reals);

#endif


return EXIT_SUCCESS;
}
catch (char const* msg) {
Expand Down
2 changes: 1 addition & 1 deletion docker/build_release_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# example would be to strace an executable to find its dependencies

MAJOR=v3
MINOR=73
MINOR=74
VERSION="$MAJOR.$MINOR"

if [[ $# == 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion docker/build_test_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# example would be to strace an executable to find its dependencies

MAJOR=v3
MINOR=73
MINOR=74
VERSION="$MAJOR.$MINOR"

if [[ $# == 0 ]]; then
Expand Down
Loading

0 comments on commit 7af781f

Please sign in to comment.