-
Notifications
You must be signed in to change notification settings - Fork 11
Implement Exponentiation via Associative Iteration #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
530543a
c600842
3b9f000
07952f5
bc27994
264dce9
9943917
acdaa6f
4eace36
88360cf
4801e56
582affe
78be7f7
48f9604
bee7202
332bd67
a2e30d6
7d8379f
20e7f42
bf2be04
3af74ee
c83ac4a
4261a23
f665142
cb496ca
449de1f
756a5ee
0d8fa58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# Vscode does not like to build outside of the source tree | ||
# (multiple glitches) | ||
|
||
.vscode | ||
test/.vscode | ||
build | ||
.cache | ||
|
||
.vscode | ||
test/.vscode | ||
build | ||
.cache | ||
.idea | ||
**cmake-build** | ||
|
||
# Vscode does not like to build outside of the source tree | ||
# (multiple glitches) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
#include <iostream> | ||
#include <type_traits> | ||
|
||
|
||
using namespace zoo; | ||
using namespace zoo::swar; | ||
|
||
|
@@ -64,8 +63,31 @@ static_assert( | |
multiplication_OverflowUnsafe_SpecificBitCount<3>(Micand, Mplier).value() | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GOOD NEWS. Looks like my initial, first-pass implementation was correct after all! All value I tried when evaluating using the hex idiom you guys have already got provides consistently correct answers. |
||
static_assert(0b00000010000000110000010100000110 == 0x02'03'05'06); | ||
|
||
TEST_CASE("Expontiation with 8-bit lane width (overflow unsafe)") { | ||
using S = SWAR<8, u32>; | ||
constexpr auto base = S::fromLaneLiterals({2, 3, 5, 6}); | ||
constexpr auto exponent = S::fromLaneLiterals({7, 4, 2, 3}); | ||
constexpr auto expected = S::fromLaneLiterals({128, 81, 25, 216}); | ||
constexpr auto actual = exponentiation_OverflowUnsafe(base, exponent); | ||
static_assert(expected.value() == actual.value()); | ||
CHECK(expected.value() == actual.value()); | ||
} | ||
|
||
TEST_CASE("Expontiation with 16-bit lane width (overflow unsafe)") { | ||
using S = SWAR<16, u64>; // Change to 16-bit lane width | ||
constexpr auto base = S::fromLaneLiterals({10, 2, 7, 3}); | ||
constexpr auto exponent = S::fromLaneLiterals({3, 5, 1, 4}); | ||
constexpr auto expected = S::fromLaneLiterals({1000, 32, 7, 81}); | ||
constexpr auto actual = exponentiation_OverflowUnsafe(base, exponent); | ||
static_assert(expected.value() == actual.value()); | ||
CHECK(expected.value() == actual.value()); | ||
} | ||
|
||
}; | ||
|
||
|
||
#define HE(nbits, t, v0, v1) \ | ||
static_assert(horizontalEquality<nbits, t>(\ | ||
SWAR<nbits, t>(v0),\ | ||
|
@@ -425,7 +447,7 @@ TEST_CASE( | |
"BooleanSWAR MSBtoLaneMask", | ||
"[swar]" | ||
) { | ||
// BooleanSWAR as a mask: | ||
// BooleanSWAR as a mask: | ||
auto bswar =BooleanSWAR<4, u32>(0x0808'0000); | ||
auto mask = S4_32(0x0F0F'0000); | ||
CHECK(bswar.MSBtoLaneMask().value() == mask.value()); | ||
|
@@ -452,6 +474,6 @@ TEST_CASE( | |
CHECK(SWAR<4, u16>(0x0400).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0100), SWAR<4, u16>(0x0300)).value()); | ||
CHECK(SWAR<4, u16>(0x0B00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0300)).value()); | ||
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0700)).value()); | ||
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value()); | ||
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value()); | ||
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value()); | ||
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your IDE really require building inline with the sources, or within the source tree?
I am loathe to pollute the repository with support for the anti-pattern of building within the sources; however, Visual Studio Code forced me to yield. VSCode is a poor tool that glitches in very frustrating ways when asked to build out of the source tree, that's the only reason for the
test/.vscode
,build
and.cache
.So, unless your tool glitches, adopt the practice of not building in-tree and remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this such a bad thing? I think most tools / LSPs expect to build in the source tree? I think CLion does this by default and I think
clangd
by default looks for./build
in the root of the project?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two things I dislike:
Most tools like the command line
grep
,find
, etc. are extremely hard to configure for understanding.gitignore
, so, you just slow down your work flow by having to treat the non-sources directories as explicit special cases with every non-git tool you use.Let's say you want to build with GCC and also with Clang.
Who gets to build in-tree? both?
So, for every flavor of build you may want you need to provide an entry point within the tree, and add it to the .gitignore.
How's that helpful instead of segregating builds from sources?
These are two instances of the more general problem of disorganization. A freshly cloned repository ought to contain only files generated by people or by tools that are so sophisticated they may as well. Further processing of "sources" ought not to dump the results into a place where it is hard to tell them apart from files made by people.
It baffles me that colleagues expect that whatever configuration is good for holding source files is going to be just as good for built files. For example, what if I have a configuration of very small blocks at the file system level expecting that source code is among the very small files in the distribution of file size, but keep the build filesystem with large blocks, because of the same reason on the opposite?
See? there are multiplicity of day to day advantages of keeping things organized. Very fundamental stuff for Software Engineers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry took a while to get back to this.
I understand both of these points, I think the overriding point from me regardless of my opinion is that this is how it is going to be used by people, so we might as well make it convenient for people to contribute. Many IDEs and tools like the build folder to be in the source tree. I'm using the
clangd
LSP which is hooking into nvim which I believe requires thecompile_commands.json
to be in./build
. JetBrains also will build in the source tree by default intocmake-build-[BUILD_TYPE]
.Secondly, you can use tools like
ripgrep
in place of grep which are.gitignore
sensitive, which is awesome.Though I hear your points well and agree, this addition doesn't prevent more optimal workflows and enables anyone to contribute more easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's continue this conversation online, at this point, it is an item that should not go in this PR, but in another PR if we decide to support building in-tree.
Let's have PRs with a "single responsibility".