-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hello,
for better performance, it may be desirable to port this library to WebAssembly.
It is a bit early to try to port the whole thing, but two crucial functions can already be ported easily : 'sign' and 'grade'. It is my understanding that those two functions are a performance bottleneck, so they may be worth implementing right now.
The following C code can be compiled for instance with the WASM explorer:
typedef unsigned long int integer;
int grade(integer b);
int sign(integer a, integer b) {
integer n = a >> 1;
int sum = 0;
while (n != 0) {
sum += grade(n & b);
n >>= 1;
}
return sum&1 ? -1 : 1;
}
int grade(integer b) {
unsigned int n = 0;
while (b != 0) {
if (b&1) { n++; }
b >>= 1;
}
return n;
}
That would limit the number of vector dimensions to 32 (or 64 if we really want that), but who needs more than 32 vector dimensions anyway?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels