Skip to content

Commit

Permalink
specialized posit<16,2> engineering
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravenwater committed Dec 13, 2023
1 parent 3ab7913 commit 08fd473
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/universal/number/posit/specialized/posit_16_2.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once
// posit_16_2.hpp: specialized 16-bit posit using fast implementation specialized for posit<16,2>
//
// Copyright (C) 2017-2023 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.

// DO NOT USE DIRECTLY!
// the compile guards in this file are only valid in the context of the specialization logic
// configured in the main <universal/posit/posit>
// configured in the main <universal/number/posit/posit.hpp>

#ifndef POSIT_FAST_POSIT_16_2
#define POSIT_FAST_POSIT_16_2 0
Expand Down
18 changes: 15 additions & 3 deletions static/posit/specialized/posit_16_2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// posit_16_2.cpp: test suite runner for specialized posit<16,2>
//
// Copyright (C) 2017-2023 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>
Expand All @@ -12,6 +12,7 @@
// second: enable posit arithmetic exceptions
#define POSIT_THROW_ARITHMETIC_EXCEPTION 1
#include <universal/number/posit/posit.hpp>
#include <universal/verification/posit_test_suite.hpp>
#include <universal/verification/posit_test_randoms.hpp>
#include <universal/verification/posit_math_test_suite.hpp>

Expand All @@ -38,8 +39,8 @@ try {
using namespace sw::universal;

// configure a posit<16,2>
constexpr size_t nbits = NBITS_IS_16;
constexpr size_t es = ES_IS_2;
constexpr unsigned nbits = NBITS_IS_16;
constexpr unsigned es = ES_IS_2;

int nrOfFailedTestCases = 0;
bool bReportIndividualTestCases = false;
Expand Down Expand Up @@ -195,6 +196,17 @@ try {
nrOfFailedTestCases += ReportTestResult( VerifyPowerFunction <nbits, es>(bReportIndividualTestCases), tag, "pow ");
#endif

#ifdef EXHAUSTIVE
// arithmetic tests
std::cout << "Arithmetic tests\n";
nrOfFailedTestCases += ReportTestResult(VerifyAddition <nbits, es>(bReportIndividualTestCases), tag, "add (native) ");
nrOfFailedTestCases += ReportTestResult(VerifySubtraction <nbits, es>(bReportIndividualTestCases), tag, "subtract (native) ");
nrOfFailedTestCases += ReportTestResult(VerifyMultiplication <nbits, es>(bReportIndividualTestCases), tag, "multiply (native) ");
nrOfFailedTestCases += ReportTestResult(VerifyDivision <nbits, es>(bReportIndividualTestCases), tag, "divide (native) ");
nrOfFailedTestCases += ReportTestResult(VerifyNegation <nbits, es>(bReportIndividualTestCases), tag, "negate (native) ");
nrOfFailedTestCases += ReportTestResult(VerifyReciprocation <nbits, es>(bReportIndividualTestCases), tag, "reciprocate (native) ");
#endif

#endif // MANUAL_TESTING
std::cout << std::flush;

Expand Down

0 comments on commit 08fd473

Please sign in to comment.