Skip to content

Commit

Permalink
V3.69 Enabling Apple M1 silicon (#334)
Browse files Browse the repository at this point in the history
* WIP: getting Apple Silicon enabled

* standard test suite structure for two_sum

* standard posits fail the twoSum test of floating-point: ignore failures

* disabling pure C API library build: clang is failing

* bug fix on numeric_limits of cfloats

* additional clarity to explain numeric_limits

* WIP: long doubles in x86 and arm are different, need to accomodate

* compilation warning removal for clang

* compilation fix for f2s debug

* remove clang compiler warnings for lns arithmetic tests

* WIP: streamlining dot error benchmark

* expanding type_tag to integral types to compensate for gcc and clang symbol mangling

* moving to clang14 in devcontainer

* bug fix on float bit manipulation

* adding Clang15 and Clang16 to the dev and build containers

* adding build container for Clang16

* fix spelling error to identify ARM processor

* disabling static asserts in float to string prototype

* restructuring the nonconst floating-point field extraction functionality

* bug fix clang build

---------

Co-authored-by: Theodore Omtzigt <theo@lemurianlabs.com>
  • Loading branch information
Ravenwater and theo-lemurian committed Apr 24, 2023
1 parent bcd1f07 commit bab326c
Show file tree
Hide file tree
Showing 58 changed files with 1,482 additions and 756 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:clang11builder"
"image": "stillwater/universal:clang14builder"
}
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.68, main ]
branches: [ v3.69, main ]
pull_request:
branches: [ main ]

Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ endmacro()


# Use cmake scripts and modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ools/cmake")
trace_variable(CMAKE_MODULE_PATH)

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
Expand Down Expand Up @@ -582,7 +582,7 @@ if(BUILD_ALL)
set(BUILD_LINEAR_ALGEBRA_VMATH ON)

# build the C API library
set(BUILD_C_API_PURE_LIB ON)
#set(BUILD_C_API_PURE_LIB ON)
set(BUILD_C_API_SHIM_LIB ON)

# build the HW validation environment
Expand Down Expand Up @@ -848,6 +848,7 @@ endif(BUILD_BENCHMARK_ENERGY)
# command line tools and utilities
if(BUILD_CMD_LINE_TOOLS)
add_subdirectory("tools/cmd")
add_subdirectory("tools/utils")
endif(BUILD_CMD_LINE_TOOLS)

# educational examples
Expand Down
65 changes: 33 additions & 32 deletions applications/floating-point/two_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
//
// This file is part of the UNIVERSAL project, which is released under an MIT Open Source license.
#include <universal/number/posit/posit.hpp>
#include <universal/verification/test_status.hpp> // ReportTestResult
#include <universal/verification/posit_test_suite.hpp>
#include <universal/verification/test_suite.hpp>

/*
important properties of linear floating point arithmetic:
Expand Down Expand Up @@ -118,22 +117,20 @@ int ValidateTwoSum(const std::string& tag, bool reportTestCases) {

#define MANUAL_TEST 0

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

// print detailed bit-level computational intermediate results
// bool verbose = false;

std::string test_suite = "application two-sum";
std::string test_tag = "two-sum";
bool reportTestCases = true;
int nrOfFailedTestCases = 0;
bool reportTestCases = true;
std::string tag = "TwoSum failed: ";

// preserve the existing ostream precision
auto precision = std::cout.precision();
std::cout << std::setprecision(12);

std::cout << "Posit TwoSum validation" << '\n';
ReportTestSuiteHeader(test_suite, reportTestCases);

#if MANUAL_TEST

Expand All @@ -155,40 +152,44 @@ try {
++a;
std::cout << a.get() << " : " << a << " : sum(a,a) " << a + a << " : " << (a + a).get() << '\n';

ReportTestSuiteResults(test_suite, nrOfFailedTestCases);
return EXIT_SUCCESS; // ignore failures
#else
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<2, 0>(tag, reportTestCases), "posit<2,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<2, 0>(test_tag, reportTestCases), "posit<2,0>", "twoSum");

nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<3, 0>(tag, reportTestCases), "posit<3,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<3, 1>(tag, reportTestCases), "posit<3,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<3, 0>(test_tag, reportTestCases), "posit<3,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<3, 1>(test_tag, reportTestCases), "posit<3,1>", "twoSum");

nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 0>(tag, reportTestCases), "posit<4,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 1>(tag, reportTestCases), "posit<4,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 2>(tag, reportTestCases), "posit<4,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 0>(test_tag, reportTestCases), "posit<4,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 1>(test_tag, reportTestCases), "posit<4,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<4, 2>(test_tag, reportTestCases), "posit<4,2>", "twoSum");

nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 0>(tag, reportTestCases), "posit<5,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 1>(tag, reportTestCases), "posit<5,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 2>(tag, reportTestCases), "posit<5,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 3>(tag, reportTestCases), "posit<5,3>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 0>(test_tag, reportTestCases), "posit<5,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 1>(test_tag, reportTestCases), "posit<5,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 2>(test_tag, reportTestCases), "posit<5,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<5, 3>(test_tag, reportTestCases), "posit<5,3>", "twoSum");

nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 0>(tag, reportTestCases), "posit<6,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 1>(tag, reportTestCases), "posit<6,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 2>(tag, reportTestCases), "posit<6,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 3>(tag, reportTestCases), "posit<6,3>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 4>(tag, reportTestCases), "posit<6,4>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 0>(test_tag, reportTestCases), "posit<6,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 1>(test_tag, reportTestCases), "posit<6,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 2>(test_tag, reportTestCases), "posit<6,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 3>(test_tag, reportTestCases), "posit<6,3>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<6, 4>(test_tag, reportTestCases), "posit<6,4>", "twoSum");

nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 0>(tag, reportTestCases), "posit<8,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 1>(tag, reportTestCases), "posit<8,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 2>(tag, reportTestCases), "posit<8,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 3>(tag, reportTestCases), "posit<8,3>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 4>(tag, reportTestCases), "posit<8,4>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 5>(tag, reportTestCases), "posit<8,5>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 0>(test_tag, reportTestCases), "posit<8,0>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 1>(test_tag, reportTestCases), "posit<8,1>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 2>(test_tag, reportTestCases), "posit<8,2>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 3>(test_tag, reportTestCases), "posit<8,3>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 4>(test_tag, reportTestCases), "posit<8,4>", "twoSum");
nrOfFailedTestCases += ReportTestResult(ValidateTwoSum<8, 5>(test_tag, reportTestCases), "posit<8,5>", "twoSum");

#endif // MANUAL_TEST
ReportTestSuiteResults(test_suite, nrOfFailedTestCases);

// restore the previous ostream precision
std::cout << std::setprecision(precision);

return EXIT_SUCCESS;
//return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
return EXIT_SUCCESS; // standard posits fail the twoSum test of floating-point, so ignore failures
#endif // MANUAL_TEST
}
catch (char const* msg) {
std::cerr << "Caught ad-hoc exception: " << msg << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions applications/numeric/numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// 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/utility/compiler_environment.hpp>
#include <universal/utility/compiler.hpp>
#include <cstddef>
#include <stdexcept>
#include <cstring>
Expand Down Expand Up @@ -121,7 +121,7 @@ try {

std::cout << "high-precision constants\n";

report_compiler_environment();
report_compiler();

using int32 = integer<32, std::uint32_t>;
using fixpnt32 = fixpnt<32, 16, Modulo, std::uint32_t>;
Expand Down
177 changes: 0 additions & 177 deletions applications/numeric/posit_distribution.hpp

This file was deleted.

0 comments on commit bab326c

Please sign in to comment.