Skip to content

Commit

Permalink
API change complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravenwater committed May 9, 2021
1 parent 7e46deb commit 77ea546
Show file tree
Hide file tree
Showing 53 changed files with 416 additions and 427 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(NOT DEFINED UNIVERSAL_VERSION_MAJOR)
set(UNIVERSAL_VERSION_MAJOR 3)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_MINOR)
set(UNIVERSAL_VERSION_MINOR 9)
set(UNIVERSAL_VERSION_MINOR 10)
endif()
if(NOT DEFINED UNIVERSAL_VERSION_PATCH)
set(UNIVERSAL_VERSION_PATCH 1)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN cmake -DBUILD_CI_CHECK=ON .. && make
# the command 'make test' is run as part of the CI test pipeline of the release container

# add a command that when you run the container without a command, it produces something meaningful
CMD ["echo", "Universal Numbers Library Builder Version 3.8.1"]
CMD ["echo", "Universal Numbers Library Builder Version 3.10.1"]


# RELEASE stage
Expand Down Expand Up @@ -111,4 +111,4 @@ WORKDIR /home/stillwater/universal/build

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

CMD ["echo", "Universal Numbers Library Version 3.8.1"]
CMD ["echo", "Universal Numbers Library Version 3.10.1"]
6 changes: 3 additions & 3 deletions benchmark/performance/arithmetic/areal/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void DecodeWorkload(uint64_t NR_OPS) {
size_t success{ 0 };
bool first{ true };
for (uint64_t i = 0; i < NR_OPS; ++i) {
a.set_raw_bits(i);
a.setBits(i);
bool s{ false };
blockbinary<a.es, typename Scalar::BlockType> e;
blockbinary<a.fbits, typename Scalar::BlockType> f;
Expand Down Expand Up @@ -89,7 +89,7 @@ areal<32,8,uint32_t> decode 1000000 per 0.0465827sec -> 21
areal<64,11,uint64_t> decode 1000000 per 0.104031sec -> 9 Mops/sec
2/26/2021
AREAL decode operator performance <--- this includes set_raw_bits() so we have more dynamic behavior of the test
AREAL decode operator performance <--- this includes setBits() so we have more dynamic behavior of the test
areal<8,2,uint8_t> decode 1000000 per 0.0017149sec -> 583 Mops/sec
areal<16,5,uint16_t> decode 1000000 per 0.0015602sec -> 640 Mops/sec
areal<32,8,uint32_t> decode 1000000 per 0.0021211sec -> 471 Mops/sec
Expand Down Expand Up @@ -153,7 +153,7 @@ try {

using Scalar = areal<64, 11, uint64_t>;
Scalar a;
a.set_raw_bits(0xEEEEEEEEEEEEEEEEull);
a.setBits(0xEEEEEEEEEEEEEEEEull);
bool s{ false };
blockbinary<a.es, typename Scalar::BlockType> e;
blockbinary<a.fbits, typename Scalar::BlockType> f;
Expand Down
10 changes: 5 additions & 5 deletions benchmark/performance/arithmetic/bfloat/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void CopyWorkload(uint64_t NR_OPS) {
bool bFail = false;
size_t j = 0;
for (size_t i = 0; i < NR_OPS; ++i,++j) {
a.set_raw_bits(i);
a.setBits(i);
b = a;
c.set_raw_bits(j);
c.setBits(j);
if (b.sign() != c.sign()) {
bFail = true;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void DecodeWorkload(uint64_t NR_OPS) {
size_t success{ 0 };
bool first{ true };
for (uint64_t i = 0; i < NR_OPS; ++i) {
a.set_raw_bits(i);
a.setBits(i);
bool s{ false };
blockbinary<a.es, typename Scalar::BlockType> e;
blockbinary<a.fbits, typename Scalar::BlockType> f;
Expand All @@ -168,7 +168,7 @@ void DecodeWorkload(uint64_t NR_OPS) {

/*
2/26/2021
BFLOAT decode operator performance <---- this includes set_raw_bits()
BFLOAT decode operator performance <---- this includes setBits()
bfloat<8,2,uint8_t> decode 10000000 per 0.0105318sec -> 949 Mops/sec
bfloat<16,5,uint16_t> decode 10000000 per 0.017448sec -> 573 Mops/sec
bfloat<32,8,uint32_t> decode 10000000 per 0.0158896sec -> 629 Mops/sec
Expand Down Expand Up @@ -281,7 +281,7 @@ void NormalizeWorkload(uint64_t NR_OPS) {

bool bFail = false;
for (uint64_t i = 0; i < NR_OPS; ++i) {
a.set_raw_bits(i);
a.setBits(i);
a.normalize(b);
if (a.sign() != b.sign()) {
// cout << to_binary(a, true) << " : " << to_triple(b, true) << '\n';
Expand Down
2 changes: 1 addition & 1 deletion c_api/shim/posit/posit_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ template<size_t nbits, size_t es, class positN_t> class convert_bytes : convert<
sw::universal::posit<nbits, es> pa;
sw::universal::bitblock<nbits> raw;
marshal<nbits,es>(bits, raw);
pa.set(raw);
pa.setBitblock(raw);
return pa;
}
static positN_t encode(sw::universal::posit<nbits, es> p) {
Expand Down
4 changes: 2 additions & 2 deletions education/posit/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sw::universal::posit<nbits, es> convert_to_posit(Ty rhs) {
if (check_inward_projection_range<nbits, es>(_scale)) { // regime dominated
// we are projecting to minpos/maxpos
int k = calculate_unconstrained_k<nbits, es>(_scale);
k < 0 ? p.set(minpos_pattern<nbits, es>(_sign)) : p.set(maxpos_pattern<nbits, es>(_sign));
k < 0 ? p.setBitblock(minpos_pattern<nbits, es>(_sign)) : p.setBitblock(maxpos_pattern<nbits, es>(_sign));
// we are done
std::cout << "projection rounding ";
}
Expand Down Expand Up @@ -140,7 +140,7 @@ sw::universal::posit<nbits, es> convert_to_posit(Ty rhs) {
cout << ptt << " rounded posit\n";
if (s) ptt = twos_complement(ptt);
cout << ptt << " final posit\n";
p.set(ptt);
p.setBitblock(ptt);
}
return p;
}
Expand Down
70 changes: 35 additions & 35 deletions education/posit/raw_bit_patterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ void EnumerateRegimePatterns() {
// start with NaR
raw.reset();
raw[nbits - 1] = true;
p.set(raw); std::cout << raw << " " << p << std::endl;
p.setBitblock(raw); std::cout << raw << " " << p << std::endl;
// move to maxpos
raw.flip();
p.set(raw); std::cout << raw << " " << p << std::endl;
p.setBitblock(raw); std::cout << raw << " " << p << std::endl;
// enumerate to 1
for (int i = 0; i < int(nbits) - 2; i++) {
raw[i] = false;
p.set(raw); std::cout << raw << " " << p << std::endl;
p.setBitblock(raw); std::cout << raw << " " << p << std::endl;
}

// enumerate to 0from 1.0 to minpos and finally 0
for (int i = int(nbits) - 3; i >= 0; --i) {
raw[i + 1] = false;
raw[i] = true;
p.set(raw); std::cout << raw << " " << p << std::endl;
p.setBitblock(raw); std::cout << raw << " " << p << std::endl;
}
// and the last pattern, encoding 0
raw[0] = false;
p.set(raw); std::cout << raw << " " << p << std::endl;
p.setBitblock(raw); std::cout << raw << " " << p << std::endl;
}

int main()
Expand Down Expand Up @@ -104,78 +104,78 @@ void ManualPatternSet() {
using namespace std;
cout << setprecision(34);
raw[15] = 1; // NaR (Not a Real)
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.flip(); // 72057594037927936
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[0] = false; // 4503599627370496
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[1] = false; // 281474976710656
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[2] = false; // 17592186044416
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[3] = false; // 1099511627776
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[4] = false; // 68719476736
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[5] = false; // 4294967296
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[6] = false; // 268435456
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[7] = false; // 16777216
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[8] = false; // 1048576
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[9] = false; // 65536
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[10] = false; // 4096
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[11] = false; // 256
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[12] = false; // 16
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[13] = false; // 1
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';

raw.reset();
// positive fractional regime 1 - 0
raw[13] = true; // 1
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[12] = true; // 1/16
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[11] = true; // 1/256
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[10] = true; // 1/4096
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[9] = true; // 1/65536
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[8] = true; // 1/1048576
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[7] = true; // 1/16777216
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[6] = true; // 1/268435456
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[5] = true; // 1/4294967296
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[4] = true; // 1/68719476736
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[3] = true; // 1/1099511627776
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[2] = true; // 1/17592186044416
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw.reset();
raw[1] = true; // 1/281474976710656
p.set(raw); cout << raw << " " << p << '\n';
p.setBitblock(raw); cout << raw << " " << p << '\n';
raw[1] = false; // 0
p.set(raw); cout << raw << " " << p << " 0" << endl;
p.setBitblock(raw); cout << raw << " " << p << " 0" << endl;
}
4 changes: 2 additions & 2 deletions education/tables/fixpnts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void GenerateFixedPointTable(std::ostream& ostr, bool csvFormat = false) {
ostr << "\"Generate Fixed-Point Lookup table for a FIXPNT<" << nbits << "," << rbits << "> in CSV format\"" << std::endl;
ostr << "#, Binary, sign, scale, value\n";
for (size_t i = 0; i < size; i++) {
p.set_raw_bits(i);
p.setBits(i);
ostr << i << ","
<< to_binary(p) << ","
<< p.sign() << ","
Expand Down Expand Up @@ -59,7 +59,7 @@ void GenerateFixedPointTable(std::ostream& ostr, bool csvFormat = false) {
<< std::setw(format_column) << "format"
<< std::endl;
for (size_t i = 0; i < size; i++) {
p.set_raw_bits(i);
p.setBits(i);
ostr << std::setw(4) << i << ": "
<< std::setw(bin_column) << to_binary(p)
<< std::setw(sign_column) << p.sign()
Expand Down
24 changes: 12 additions & 12 deletions include/universal/internal/blockbinary/blockbinary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ template<size_t nbits, typename bt = uint8_t>
constexpr blockbinary<nbits, bt>& maxpos(blockbinary<nbits, bt>& a) {
a.clear();
a.flip();
a.reset(nbits - 1);
a.setBit(nbits - 1, false);
return a;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ class blockbinary {
}
blockbinary& operator++() {
blockbinary increment;
increment.set_raw_bits(0x1);
increment.setBits(0x1);
*this += increment;
return *this;
}
Expand All @@ -189,7 +189,7 @@ class blockbinary {
}
blockbinary& operator--() {
blockbinary decrement;
decrement.set_raw_bits(0x1);
decrement.setBits(0x1);
return *this -= decrement;
}
// logic operators
Expand Down Expand Up @@ -359,7 +359,7 @@ class blockbinary {
_block[i / bitsInBlock] = bt((block & null) | mask);
return;
}
throw "blockbinary<nbits, bt>.set(index): bit index out of bounds";
throw "blockbinary<nbits, bt>.setBit(index): bit index out of bounds";
}
inline constexpr void setBits(uint64_t value) noexcept {
if constexpr (1 == nrBlocks) {
Expand Down Expand Up @@ -745,8 +745,8 @@ inline blockbinary<2 * nbits, bt> urmul2(const blockbinary<nbits, bt>& a, const
// normalize both arguments to positive in new size
blockbinary<nbits + 1, bt> a_new(a); // TODO optimize: now create a, create _a.bb, copy, destroy _a.bb_copy
blockbinary<nbits + 1, bt> b_new(b);
if (a.sign()) a_new.twoscomplement();
if (b.sign()) b_new.twoscomplement();
if (a.sign()) a_new.twosComplement();
if (b.sign()) b_new.twosComplement();
blockbinary<2*nbits, bt> multiplicant(b_new);

#if TRACE_URMUL
Expand All @@ -762,7 +762,7 @@ inline blockbinary<2 * nbits, bt> urmul2(const blockbinary<nbits, bt>& a, const
std::cout << std::setw(3) << i << ' ' << multiplicant << ' ' << result << std::endl;
#endif
}
if (result_sign) result.twoscomplement();
if (result_sign) result.twosComplement();
#if TRACE_URMUL
std::cout << "fnl " << result << std::endl;
#endif
Expand All @@ -786,8 +786,8 @@ inline blockbinary<2 * nbits + roundingBits, bt> urdiv(const blockbinary<nbits,
// normalize both arguments to positive in new size
blockbinary<nbits + 1, bt> a_new(a); // TODO optimize: now create a, create _a.bb, copy, destroy _a.bb_copy
blockbinary<nbits + 1, bt> b_new(b);
if (a_sign) a_new.twoscomplement();
if (b_sign) b_new.twoscomplement();
if (a_sign) a_new.twosComplement();
if (b_sign) b_new.twosComplement();

// initialize the long division
blockbinary<2 * nbits + roundingBits, bt> decimator(a_new);
Expand All @@ -812,10 +812,10 @@ inline blockbinary<2 * nbits + roundingBits, bt> urdiv(const blockbinary<nbits,

if (subtractand <= decimator) {
decimator -= subtractand;
result.set(static_cast<size_t>(i));
result.setBit(static_cast<size_t>(i));
}
else {
result.reset(static_cast<size_t>(i));
result.setBit(static_cast<size_t>(i), false);
}
subtractand >>= 1;

Expand All @@ -825,7 +825,7 @@ inline blockbinary<2 * nbits + roundingBits, bt> urdiv(const blockbinary<nbits,
#endif
}
result <<= scale;
if (result_negative) result.twoscomplement();
if (result_negative) result.twosComplement();
r.assign(result); // copy the lowest bits which represent the bits on which we need to apply the rounding test
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion include/universal/number/adaptivefloat/adaptivefloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class adaptivefloat {
inline void clear() { sign = false; exp = 0; coef.clear(); }
inline void setzero() { clear(); }
// use un-interpreted raw bits to set the bits of the adaptivefloat
inline void set_raw_bits(unsigned long long value) {
inline void setBits(unsigned long long value) {
clear();
}
inline adaptivefloat& assign(const std::string& txt) {
Expand Down
2 changes: 1 addition & 1 deletion include/universal/number/adaptiveint/adaptiveint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class adaptiveint {
inline void clear() { sign = false; exp = 0; coef.clear(); }
inline void setzero() { clear(); }
// use un-interpreted raw bits to set the bits of the adaptiveint
inline void set_raw_bits(unsigned long long value) {
inline void setBits(unsigned long long value) {
clear();
}
inline adaptiveint& assign(const std::string& txt) {
Expand Down
Loading

0 comments on commit 77ea546

Please sign in to comment.