Skip to content
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

Add type-specialized vectorized hash table container #100386

Merged
merged 113 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
6df2ffc
Checkpoint dn_simdhash
kg Mar 27, 2024
2f41984
Checkpoint
kg Mar 27, 2024
059705b
Checkpoint
kg Mar 27, 2024
0017d53
Checkpoint
kg Mar 28, 2024
2cc6a91
Checkpoint
kg Mar 28, 2024
6cf488d
Checkpoint
kg Mar 28, 2024
368c076
Checkpoint
kg Mar 28, 2024
ebc7b97
Checkpoint
kg Mar 28, 2024
335b32e
Checkpoint
kg Mar 28, 2024
12487c8
Checkpoint
kg Mar 28, 2024
9bfc7b6
Add missing files
kg Mar 28, 2024
5b8fec5
Checkpoint
kg Mar 28, 2024
5408f27
Add missing header
kg Mar 28, 2024
8cbf1db
Cleanups and more comments
kg Mar 28, 2024
a3d8622
Checkpoint
kg Mar 28, 2024
53ef795
Fix insertion
kg Mar 28, 2024
0d57f12
Remove generic add and get, they complicate everything for no reason
kg Mar 28, 2024
4a194da
Build fix
kg Mar 28, 2024
e6e29ef
Build fixes
kg Mar 28, 2024
406614b
Cleanup
kg Mar 28, 2024
9c1ed15
When cascading, wrap around to the first bucket when we reach the end…
kg Mar 28, 2024
69cd351
Simplify declaring specializations
kg Mar 28, 2024
58045c1
Cleanup
kg Mar 28, 2024
f354798
Convert spaces to tabs
kg Mar 28, 2024
4fa00c8
Rearrange things so that find_first_matching_suffix gets inlined
kg Mar 28, 2024
48faef8
Basic removal implementation
kg Mar 28, 2024
ab63d5f
Expand tests
kg Mar 28, 2024
ee87e52
Build fixes
kg Mar 28, 2024
bcf8be0
Cleanup
kg Mar 28, 2024
f9db166
MSVC doesn't support warning preprocessor command so use pragma message
kg Mar 28, 2024
8c3efe5
Fix build
kg Mar 28, 2024
ece1efe
Fix build
kg Mar 28, 2024
65862c1
Fix linker problem by defining string comparison and hasher inline
kg Mar 28, 2024
0aaffc2
Match semantics of ghashtable better
kg Mar 28, 2024
24cf824
Checkpoint
kg Mar 28, 2024
5a1af2e
dn_allocator allocations aren't zeroed :)
kg Mar 28, 2024
ff3678a
Cleanup
kg Mar 28, 2024
66b8a19
Use dn_simdhash_string_ptr for namespace lookup cache
kg Mar 28, 2024
9f15f25
Fix build
kg Mar 28, 2024
5011da6
Allow hiding the default specializations of a simdhash so you can wra…
kg Mar 28, 2024
0eb125e
Cache the hashcode of keys in string_ptr since it makes natural cache…
kg Mar 28, 2024
fde9544
Rearrange things to fix C4505
kg Mar 28, 2024
4949c53
Prohibit declaring multiple specializations in one .c file since it w…
kg Mar 28, 2024
c5ce9b2
Maybe fix duplicate include
kg Mar 28, 2024
f99f2cc
Fix use of base foreach for string_ptr hashtable
kg Mar 28, 2024
c848322
Annotate fallthrough in murmurhash for clang
kg Mar 28, 2024
c1a8001
Manually unroll the murmurhash3 duff's device to satisfy clang
kg Mar 28, 2024
d4031a1
Oops
kg Mar 28, 2024
b00cd4a
Fix leaked dn_simdhash_t instance
kg Mar 28, 2024
24d4b84
Cleanup
kg Mar 28, 2024
df8d8f4
Fix truncation warning with 64-bit strlen
kg Mar 29, 2024
e13f48e
Workaround linux x64 linker problem
kg Mar 29, 2024
cb2eb95
Fix GCC build parse error
kg Mar 29, 2024
ef9a132
Cleanup & rearrange things; attempt to fix GCC build
kg Mar 29, 2024
5923050
Updates so test suite works again; verified on linux x64 gcc
kg Mar 29, 2024
099a953
Fix indentation
kg Mar 29, 2024
d6f2bb7
Cleanup
kg Mar 29, 2024
6504f19
Fix foreaches
kg Mar 29, 2024
a47fea2
Split architecture-specific stuff into its own header
kg Mar 29, 2024
8fb0a5a
Specializing foreach means key_is_pointer/value_is_pointer aren't needed
kg Mar 29, 2024
e86c5c4
Cleanup
kg Mar 29, 2024
7b2c15d
Simplify preprocessor token gluing
kg Mar 29, 2024
c22b3d7
Cleanup and improve comments
kg Mar 29, 2024
9708bfa
Align the address of the first bucket
kg Mar 29, 2024
e11fa7d
Comment out neon for now
kg Mar 29, 2024
5525995
Cleanup
kg Mar 29, 2024
3f84231
Alignment and arch-specific pointer size fixes
kg Mar 29, 2024
441079a
Fix ARM clang/gcc build
kg Mar 29, 2024
480432f
Maybe fix CI-specific build issue
kg Mar 29, 2024
ffbfd0f
MSVC docs were wrong :(
kg Mar 29, 2024
1ca0206
Cleanup
kg Mar 29, 2024
4685237
Silence MSVC warnings again
kg Mar 29, 2024
6548031
Rework string_ptr to avoid pre-computing string length, and use a str…
kg Mar 30, 2024
14155c8
Cleanup
kg Mar 30, 2024
dbad5d6
Add dn_simdhash_u32_ptr and use it in mono_image_init_name_cache
kg Mar 30, 2024
6ffe793
Add missing file
kg Mar 30, 2024
c3ea833
Fix type mismatch
kg Apr 1, 2024
4169252
No need to eagerly load the suffixes, and doing so makes scalar fallb…
kg Apr 2, 2024
338b23c
Optimize scalar fallback
kg Apr 2, 2024
f17bd49
Migrate all simdhash fixes and changes from simdhash-2 into simdhash …
kg Apr 3, 2024
d62c7c2
Enable ARM NEON support in simdhash since we have system headers now
kg Apr 4, 2024
31eb0ba
Update utils header from successor branch
kg Apr 8, 2024
4d0150f
Dedupe + improve 64-bit pointer hash
kg Apr 8, 2024
18806f3
Fix windows build
kg Apr 8, 2024
27ac09f
Address PR feedback
kg Apr 10, 2024
39747d0
Broken attempt at configurable assertions
kg Apr 11, 2024
c11823d
Migrate updates from simdhash-2 to simdhash-1
kg Apr 11, 2024
e08be1b
Refactor search vectors
kg Apr 11, 2024
391a5d8
Update assertions
kg Apr 11, 2024
0a1936e
Optimize out unaligned 16-byte copy in scalar wasm find_value
kg Apr 11, 2024
e388a1d
Workaround for weird msimd128 codegen
kg Apr 11, 2024
b4d07d7
Update comments
kg Apr 11, 2024
703a607
Simplify assertions
kg Apr 12, 2024
73c505d
Benchmark harness
kg Apr 12, 2024
97a3b25
Checkpoint
kg Apr 12, 2024
391fdeb
Checkpoint
kg Apr 12, 2024
ae69695
Better missing key measurement
kg Apr 12, 2024
f543c20
Fix sequential/random measurements being meaningfully different
kg Apr 12, 2024
07c398b
Adjustment based on benchmarking
kg Apr 12, 2024
44a7bd3
Add a baseline measurement
kg Apr 12, 2024
9572863
Basic ghashtable comparison measurements
kg Apr 12, 2024
bf03cca
Update makefile
kg Apr 12, 2024
57e6aa2
Check in missing changes; fix mono link error
kg Apr 12, 2024
9107045
Add missing license headers
kg Apr 12, 2024
3d066cc
Partially unroll scalar search for better wasm performance
kg Apr 12, 2024
06efeeb
Fully unroll
kg Apr 13, 2024
8d798f8
Cleanup whitespace / add comment
kg Apr 13, 2024
253d920
Only type-check simdhash instances in debug builds
kg Apr 13, 2024
d90828a
Update makefile switches
kg Apr 13, 2024
5f49036
Fix and add comments
kg Apr 15, 2024
1f2b89f
Make test support windows
kg Apr 15, 2024
5083f40
Make it possible to build benchmark suite using MSVC
kg Apr 15, 2024
af63c5c
Improve MSVC codegen
kg Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make test support windows
Fix typo in simdhash-arch MSVC implementation
  • Loading branch information
kg committed Apr 15, 2024
commit 1f2b89fa2527f59d34ff90a203e8f97d8b8d9f48
8 changes: 4 additions & 4 deletions src/native/containers/dn-simdhash-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ ctz (uint32_t value)

#include <emmintrin.h>

typedef struct {
__m128i m128;
uint8_t values[DN_SIMDHASH_VECTOR_WIDTH];
typedef union {
_Alignas(DN_SIMDHASH_VECTOR_WIDTH) __m128i m128;
_Alignas(DN_SIMDHASH_VECTOR_WIDTH) uint8_t values[DN_SIMDHASH_VECTOR_WIDTH];
} dn_simdhash_suffixes;

typedef dn_simdhash_suffixes dn_simdhash_search_vector;
Expand Down Expand Up @@ -210,7 +210,7 @@ find_first_matching_suffix (
#endif

typedef struct {
uint8_t values[DN_SIMDHASH_VECTOR_WIDTH];
_Alignas(DN_SIMDHASH_VECTOR_WIDTH) uint8_t values[DN_SIMDHASH_VECTOR_WIDTH];
} dn_simdhash_suffixes;

typedef uint8_t dn_simdhash_search_vector;
Expand Down
30 changes: 27 additions & 3 deletions src/native/containers/dn-simdhash-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

#ifdef _MSC_VER
#include <windows.h>
#define MTICKS_PER_SEC (10 * 1000 * 1000)
#else
#include <sys/time.h>
#endif

#include "dn-vector.h"
#include "dn-simdhash.h"
Expand All @@ -19,8 +25,8 @@ typedef struct {

void
dn_simdhash_assert_fail (const char *file, int line, const char *condition) {
printf("simdhash assertion failed at %s:%i:\n%s\n", file, line, condition);
fflush(stdout);
printf("simdhash assertion failed at %s:%i:\n%s\n", file, line, condition);
fflush(stdout);
}

static DN_FORCEINLINE(uint8_t)
Expand Down Expand Up @@ -75,13 +81,31 @@ void foreach_callback (size_t key, size_t value, void * user_data) {
}

int64_t get_100ns_ticks () {
#ifdef _MSC_VER
static LARGE_INTEGER freq;
static UINT64 start_time;
UINT64 cur_time;
LARGE_INTEGER value;

if (!freq.QuadPart) {
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&value);
start_time = value.QuadPart;
}
QueryPerformanceCounter(&value);
cur_time = value.QuadPart;
return (int64_t)((cur_time - start_time) * (double)MTICKS_PER_SEC / freq.QuadPart);
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return ((int64_t)tv.tv_sec * 1000000 + tv.tv_usec) * 10;
#endif
}

int main () {
const int c = 320000;
// NOTE: High values of C will cause this test to never complete if libc
// rand() is not high quality enough, i.e. MSVC 2022 on x64
const int c = 32000;
dn_simdhash_size_t_size_t_t *test = dn_simdhash_size_t_size_t_new(0, NULL);
dn_simdhash_instance_data(instance_data_t, test).f = 3.14f;
dn_simdhash_instance_data(instance_data_t, test).i = 42;
Expand Down