Skip to content

Commit

Permalink
V3.75: specialized posit enhancements (#407)
Browse files Browse the repository at this point in the history
* Bumping SEMVER to v3.75.1

* enabling CI for development branch v3.75

* codacy code hygiene fix

* code hygiene fast posit<8,2>

* properly standardizing on STL size_type throughout the Universal BLAS vector and matrix types

* codacy hygiene for Chebyshev applications

* codacy hygiene for arbitrary precision constants

* codacy hygiene for DSP and Cryptography applications

* codacy hygiene catastrophic cancellation demonstration application

* WIP: implementing a fast posit<8,2>: new float_assign algorithm

* found a fix to the weird floating-point NaN behavior in release builds: need to deal with special cases first

* adding minpos/maxpos/minneg/maxneg free functions to cfloat

* renaming reciprocate() to reciprocal() to reflect mathematical nomenclature

* removed test_tag (#406)

Signed-off-by: Theodore Omtzigt <theo@stillwater-sc.com>
Co-authored-by: Theodore Omtzigt <theo@stillwater-sc.com>

* trace variable update from reciprocate to reciprocal

* fixing reciprocal regression test when exceptions can be thrown

* WIP: bug fix in integer_assign of small specialized posits, and streamlined VerifyIntegerAssignment

* code hygiene for posit attribute functions

* codacy code hygiene

* Structuring the file system to reflect the application project organization

* adding mixed precision sin function learning DNN

* WIP: restructuring test suites to follow the same pattern

* WIP: unifying posit test suite with generic test suite API

* fix regression stress level failure for binary integer arithmetic right shift

* bug fix in regression test for elastic integer

* bug fixes in elastic decimal regression stress test

* stress level regression results

* bug fix in CMakeList.txt

* bug fix in regression level logic

* bug fix in regression logic

* simplifying the REGRESSION_LEVEL_4 to be significantly smaller to reduce running time

* cleanup on isle 5, and renaming fixed-size decimal integer build target

* WIP: creating posit number system checker: need to research what the right interpretation of INFINITY is for posits

* posit maps INFINITE to NaR

---------

Signed-off-by: Theodore Omtzigt <theo@stillwater-sc.com>
Co-authored-by: James Quinlan <james@stillwater-sc.com>
  • Loading branch information
Ravenwater and jamesquinlan authored Jan 18, 2024
1 parent e6a530d commit a587267
Show file tree
Hide file tree
Showing 328 changed files with 6,556 additions and 3,081 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"image": "stillwater/universal:clang14builder"
"image": "stillwater/universal:gcc11builder"
}
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CMake

on:
push:
branches: [ v3.74, dev, main ]
branches: [ v3.75, dev, main ]
pull_request:
branches: [ main ]

Expand Down
115 changes: 65 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@ include(tools/cmake/banners.cmake)
print_header()

####
# Set minimum version of CMake. Since we are using the VERSION option of the
# project command, we need at least 3.0. To honor the amazing work that
# the folks at KitWare have done for the open-source community, we are
# going to specify a recent version.
# As of UNIVERSAL v3.0 December 2019
# Ubuntu 16.04 LTS runs cmake 3.5
# Ubuntu 18.04 LTS runs cmake 3.10
# Ubuntu 20.04 LTS runs cmake 3.16
# Ubuntu 22.04 LTS runs cmake 3.22
# container runs cmake 3.7.1
# gcc5 container runs cmake 3.0.2
# Set minimum version of CMake.
cmake_minimum_required(VERSION 3.22)

####
Expand All @@ -35,7 +25,7 @@ if(NOT DEFINED UNIVERSAL_VERSION_MAJOR)
set(UNIVERSAL_VERSION_MAJOR 3)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_MINOR)
set(UNIVERSAL_VERSION_MINOR 74)
set(UNIVERSAL_VERSION_MINOR 75)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_PATCH)
set(UNIVERSAL_VERSION_PATCH 1)
Expand Down Expand Up @@ -221,34 +211,53 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "C++20 has been enabled by default")

# enable the regression testing level of the build
if(BUILD_REGRESSION_SANITY OR BUILD_REGRESSION_LEVEL_1)
#debug messages to troubleshoot regression level build configuration
#message(STATUS "BUILD_REGRESSION_STRESS ${BUILD_REGRESSION_STRESS} ")
#message(STATUS "BUILD_REGRESSION_SANITY ${BUILD_REGRESSION_SANITY} ")
#message(STATUS "BUILD_REGRESSION_LEVEL_1 ${BUILD_REGRESSION_LEVEL_1} ")
#message(STATUS "BUILD_REGRESSION_LEVEL_2 ${BUILD_REGRESSION_LEVEL_2} ")
#message(STATUS "BUILD_REGRESSION_LEVEL_3 ${BUILD_REGRESSION_LEVEL_3} ")
#message(STATUS "BUILD_REGRESSION_LEVEL_4 ${BUILD_REGRESSION_LEVEL_4} ")
if(BUILD_REGRESSION_STRESS)
message(STATUS "BUILD_REGRESSION_STRESS ${BUILD_REGRESSION_STRESS}")
set(BUILD_REGRESSION_LEVEL_4 ON)
set(BUILD_REGRESSION_SANITY OFF)
elseif(BUILD_REGRESSION_SANITY)
message(STATUS "BUILD_REGRESSION_SANITY ${BUILD_REGRESSION_SANITY}")
set(BUILD_REGRESSION_LEVEL_1 ON)
endif(BUILD_REGRESSION_STRESS)

if(BUILD_REGRESSION_LEVEL_4)
message(STATUS "BUILD_REGRESSION_LEVEL_4 ${BUILD_REGRESSION_LEVEL_4}")
add_definitions(-D REGRESSION_LEVEL_OVERRIDE)
add_definitions(-D REGRESSION_LEVEL_1=1)
add_definitions(-D REGRESSION_LEVEL_2=0)
add_definitions(-D REGRESSION_LEVEL_3=0)
add_definitions(-D REGRESSION_LEVEL_4=0)
endif(BUILD_REGRESSION_SANITY OR BUILD_REGRESSION_LEVEL_1)
if(BUILD_REGRESSION_LEVEL_2)
add_definitions(-D REGRESSION_LEVEL_2=1)
add_definitions(-D REGRESSION_LEVEL_3=1)
add_definitions(-D REGRESSION_LEVEL_4=1)
elseif(BUILD_REGRESSION_LEVEL_3)
message(STATUS "BUILD_REGRESSION_LEVEL_3 ${BUILD_REGRESSION_LEVEL_3}")
add_definitions(-D REGRESSION_LEVEL_OVERRIDE)
add_definitions(-D REGRESSION_LEVEL_1=1)
add_definitions(-D REGRESSION_LEVEL_2=1)
add_definitions(-D REGRESSION_LEVEL_3=0)
add_definitions(-D REGRESSION_LEVEL_3=1)
add_definitions(-D REGRESSION_LEVEL_4=0)
endif(BUILD_REGRESSION_LEVEL_2)
if(BUILD_REGRESSION_LEVEL_3)
elseif(BUILD_REGRESSION_LEVEL_2)
message(STATUS "BUILD_REGRESSION_LEVEL_2 ${BUILD_REGRESSION_LEVEL_2}")
add_definitions(-D REGRESSION_LEVEL_OVERRIDE)
add_definitions(-D REGRESSION_LEVEL_1=1)
add_definitions(-D REGRESSION_LEVEL_2=1)
add_definitions(-D REGRESSION_LEVEL_3=1)
add_definitions(-D REGRESSION_LEVEL_3=0)
add_definitions(-D REGRESSION_LEVEL_4=0)
endif(BUILD_REGRESSION_LEVEL_3)
if(BUILD_REGRESSION_STRESS OR BUILD_REGRESSION_LEVEL_4)
elseif(BUILD_REGRESSION_LEVEL_1)
message(STATUS "BUILD_REGRESSION_LEVEL_1 ${BUILD_REGRESSION_LEVEL_1}")
add_definitions(-D REGRESSION_LEVEL_OVERRIDE)
add_definitions(-D REGRESSION_LEVEL_1)
add_definitions(-D REGRESSION_LEVEL_2)
add_definitions(-D REGRESSION_LEVEL_3)
add_definitions(-D REGRESSION_LEVEL_4)
endif(BUILD_REGRESSION_STRESS OR BUILD_REGRESSION_LEVEL_4)
add_definitions(-D REGRESSION_LEVEL_1=1)
add_definitions(-D REGRESSION_LEVEL_2=0)
add_definitions(-D REGRESSION_LEVEL_3=0)
add_definitions(-D REGRESSION_LEVEL_4=0)
else(BUILD_REGRESSION_LEVEL_4)
message(STATUS "Nothing has been set")
endif(BUILD_REGRESSION_LEVEL_4)

# Compiler specific environments
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down Expand Up @@ -890,28 +899,34 @@ endif(BUILD_PLAYGROUND)

# application examples
if(BUILD_APPLICATIONS)
add_subdirectory("applications/approximation")
add_subdirectory("applications/blas")
add_subdirectory("applications/chaos")
add_subdirectory("applications/chebyshev")
add_subdirectory("applications/complex")
add_subdirectory("applications/constants")
add_subdirectory("applications/cryptography")
add_subdirectory("applications/dnn")
add_subdirectory("applications/dsp")
add_subdirectory("applications/engineering")
add_subdirectory("applications/floating-point")
add_subdirectory("applications/math")
add_subdirectory("applications/numeric")
add_subdirectory("applications/ode")
add_subdirectory("applications/optimization")
add_subdirectory("applications/pde")
add_subdirectory("applications/roots")
add_subdirectory("applications/science")
add_subdirectory("applications/sequences")
add_subdirectory("applications/accuracy/engineering")
add_subdirectory("applications/accuracy/ode")
add_subdirectory("applications/accuracy/optimization")
add_subdirectory("applications/accuracy/pde")
add_subdirectory("applications/accuracy/roots")
add_subdirectory("applications/accuracy/science")

add_subdirectory("applications/approximation/taylor")
add_subdirectory("applications/approximation/chebyshev")

add_subdirectory("applications/mixed-precision/dnn")
add_subdirectory("applications/mixed-precision/dsp")

add_subdirectory("applications/performance/chaos")
add_subdirectory("applications/performance/complex")
add_subdirectory("applications/performance/stream")
add_subdirectory("applications/performance/weather")

add_subdirectory("applications/precision/constants")
add_subdirectory("applications/precision/floating-point")
add_subdirectory("applications/precision/math")
add_subdirectory("applications/precision/numeric")

add_subdirectory("applications/reproducibility/blas")
add_subdirectory("applications/reproducibility/cryptography")
add_subdirectory("applications/reproducibility/sequences")

add_subdirectory("applications/stl")
add_subdirectory("applications/stream")
add_subdirectory("applications/weather")
endif(BUILD_APPLICATIONS)

##################################################################
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ WORKDIR /home/stillwater/universal/build

# the command 'make test' is run as part of the CI test pipeline of this release container

ENV CONTAINER_ID "Universal Numbers Library Container"
ENV CONTAINER_ID "Universal Number Systems Container"
CMD ["/usr/bin/env", "bash"]
3 changes: 3 additions & 0 deletions applications/accuracy/engineering/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file (GLOB SOURCES "./*.cpp")

compile_all("true" "engineering" "Applications/Accuracy/Engineering" "${SOURCES}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions applications/accuracy/science/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file (GLOB SOURCES "./*.cpp")

compile_all("true" "science" "Applications/Accuracy/Science" "${SOURCES}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions applications/approximation/CMakeLists.txt

This file was deleted.

3 changes: 3 additions & 0 deletions applications/approximation/chebyshev/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file (GLOB SOURCES "./*.cpp")

compile_all("true" "cheby" "Applications/Approximation/Chebyshev" "${SOURCES}")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
// CHEBPOLY(n,kind) - returns the coefficients of Chebyshev poly of the kind.
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
#pragma once
// CHEBPOLY(n,kind) - returns the coefficients of Chebyshev polynomial
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
//
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
//
// Author: James Quinlan

#pragma once

#define POSIT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/posit/posit.hpp>
#include <universal/blas/blas.hpp>

namespace chebyshev {
using namespace sw::universal;

template<typename Scalar>
blas::vector<Scalar> chebpoly(size_t n)
{
if(n<0){
std::cerr << "Parameter must be a nonnegative integer. Provided n == " << n << '\n';
return blas::vector<Scalar>(1);
}

{
blas::vector<Scalar>Tn(n+1);
if (n==0) Tn(0) = 1;
if (n==1) { Tn(0) = 0; Tn(1) = 1; }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ChebyTESTS
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
//
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
//
// Author: James Quinlan

#include <universal/utility/directives.hpp>

// Dependencies
#include<cmath> /* sin, cos, etc. */
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// nodes.cpp: Does a posit configuration exist to produce chebyshev nodes
//
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
// Copyright (C) 2017 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>

// Configure the posit library with arithmetic exceptions
// enable posit arithmetic exceptions
Expand Down Expand Up @@ -31,16 +32,14 @@ log_e(10) M_LN10 2.30258509299404568402

constexpr double pi = 3.14159265358979323846; // best practice for C++

int main(int argc, char** argv)
int main()
try {
using namespace sw::universal;

int nrOfFailedTestCases = 0;

// TBD
std::cout << "PI = " << pi << '\n';

return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
return EXIT_SUCCESS;
}
catch (char const* msg) {
std::cerr << msg << std::endl;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// nodes.cpp: Does a posit configuration exist to produce chebyshev nodes
//
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
// Copyright (C) 2017 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>
#include <cmath>
// Configure the posit library with arithmetic exceptions
// enable posit arithmetic exceptions
Expand All @@ -12,12 +13,10 @@
#include <universal/blas/blas.hpp>

// skeleton environment to experiment with Chebyshev polynomials and approximations
int main(int argc, char** argv)
int main()
try {
using namespace sw::universal::blas;

int nrOfFailedTestCases = 0;

std::cout << "Chebyshev polynomial test skeleton\n";

// using Scalar = sw::universal::fixpnt<32,16, Modulo, uint32_t>;
Expand All @@ -29,7 +28,7 @@ try {
auto cosines = -cos(k * PI / N);
std::cout << "cosines = " << cosines << '\n';

return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
return EXIT_SUCCESS;
}
catch (char const* msg) {
std::cerr << "Caught exception: " << msg << std::endl;
Expand Down
3 changes: 3 additions & 0 deletions applications/approximation/taylor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file (GLOB SOURCES "./*.cpp")

compile_all("true" "approx" "Applications/Approximation/Taylor Series" "${SOURCES}")
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// taylor_series.cpp: experiments with number systems approximating the Reals approximating functions
//
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
//
// This file is part of the UNIVERSAL project, which is released under an MIT Open Source license.
#include <universal/utility/directives.hpp>
#include <universal/number/cfloat/cfloat.hpp>
#include <universal/verification/test_suite.hpp>

Expand Down Expand Up @@ -37,14 +38,22 @@ int main()
try {
using namespace sw::universal;

std::string test_suite = "Experiments with Taylor Series Expansion";
std::string test_tag = "operator";
std::string test_suite = "Experiments with Taylor Series Expansion";
std::string test_tag = "taylor series expansion";
int nrOfFailedTestCases = 0;

std::cout << test_suite << '\n';

fp32 ca(SpecificValue::minpos), cb(SpecificValue::minpos);
float fa, fb;

fa = float(ca);
fb = float(cb);

nrOfFailedTestCases += ReportTestResult(TestCase<fp32, float>(TestCaseOperator::DIV, fa, fb), test_tag, "div");

ReportTestSuiteResults(test_suite, nrOfFailedTestCases);
return EXIT_SUCCESS;
return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
catch (char const* msg) {
std::cerr << "Caught ad-hoc exception: " << msg << std::endl;
Expand Down
3 changes: 0 additions & 3 deletions applications/chebyshev/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions applications/constants/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit a587267

Please sign in to comment.