File tree 4 files changed +70
-0
lines changed
4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 65
65
run : cargo test --verbose --target ${{ matrix.arch }}-${{ fromJSON(env.target_map)[matrix.os] }} --features=no_simd
66
66
- name : Build docs
67
67
run : cargo doc --verbose
68
+ - name : Run SIMD/no-SIMD tests
69
+ run : |
70
+ cd crosstest
71
+ cargo run
68
72
69
73
benchmarks :
70
74
strategy :
Original file line number Diff line number Diff line change 1
1
/target
2
+ /crosstest /target
2
3
Cargo.lock
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " crosstest"
3
+ version = " 0.1.0"
4
+ edition = " 2018"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies ]
9
+ odht_with_simd = { package = " odht" , version = " 0.2.1" }
10
+ odht_no_simd = { package = " odht" , path = " .." , features = [" no_simd" ] }
Original file line number Diff line number Diff line change
1
+
2
+
3
+ struct FxConfig ;
4
+
5
+ macro_rules! impl_config {
6
+ ( $odht_version: ident) => {
7
+ impl $odht_version:: Config for FxConfig {
8
+ type Key = u64 ;
9
+ type Value = u32 ;
10
+
11
+ type EncodedKey = [ u8 ; 8 ] ;
12
+ type EncodedValue = [ u8 ; 4 ] ;
13
+
14
+ type H = $odht_version:: FxHashFn ;
15
+
16
+ #[ inline]
17
+ fn encode_key( k: & Self :: Key ) -> Self :: EncodedKey {
18
+ k. to_le_bytes( )
19
+ }
20
+
21
+ #[ inline]
22
+ fn encode_value( v: & Self :: Value ) -> Self :: EncodedValue {
23
+ v. to_le_bytes( )
24
+ }
25
+
26
+ #[ inline]
27
+ fn decode_key( k: & Self :: EncodedKey ) -> Self :: Key {
28
+ u64 :: from_le_bytes( * k)
29
+ }
30
+
31
+ #[ inline]
32
+ fn decode_value( v: & Self :: EncodedValue ) -> Self :: Value {
33
+ u32 :: from_le_bytes( * v)
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ impl_config ! ( odht_no_simd) ;
40
+ impl_config ! ( odht_with_simd) ;
41
+
42
+ fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
43
+
44
+ let entries: Vec < ( u64 , u32 ) > = ( 0 .. 1_000_000_u64 ) . map ( |x| ( x * x, x as u32 ) ) . collect ( ) ;
45
+
46
+ let with_simd_table = odht_with_simd:: HashTableOwned :: < FxConfig > :: from_iterator ( entries. clone ( ) , 85 ) ;
47
+
48
+ let no_simd_table = odht_no_simd:: HashTable :: < FxConfig , _ > :: from_raw_bytes ( with_simd_table. raw_bytes ( ) ) ?;
49
+
50
+ for ( key, value) in entries {
51
+ assert_eq ! ( no_simd_table. get( & key) , Some ( value) ) ;
52
+ }
53
+
54
+ Ok ( ( ) )
55
+ }
You can’t perform that action at this time.
0 commit comments