File tree Expand file tree Collapse file tree 2 files changed +86
-0
lines changed Expand file tree Collapse file tree 2 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**************************************************************************/
2
+ /* */
3
+ /* OCaml */
4
+ /* */
5
+ /* Max Slater, Jane Street */
6
+ /* */
7
+ /* Copyright 2023 Jane Street Group LLC */
8
+ /* */
9
+ /* All rights reserved. This file is distributed under the terms of */
10
+ /* the GNU Lesser General Public License version 2.1, with the */
11
+ /* special exception on linking described in the file LICENSE. */
12
+ /* */
13
+ /**************************************************************************/
14
+
15
+ /* SIMD vector instruction support */
16
+
17
+ #ifndef CAML_SIMD_H
18
+ #define CAML_SIMD_H
19
+
20
+ #include "mlvalues.h"
21
+
22
+ #if defined(_M_IX86_FP ) || defined(__SSE2__ ) || defined(__SSE3__ ) || \
23
+ defined(__SSSE3__ ) || defined(__SSE4_1__ ) || defined(__SSE4_2__ )
24
+ #define ARCH_SSE2
25
+ #endif
26
+
27
+ #if defined(__AVX__ ) || defined(__AVX2__ )
28
+ #define ARCH_AVX
29
+ #endif
30
+
31
+ #ifdef ARCH_SSE2
32
+ #include <emmintrin.h>
33
+
34
+ #define Vec128_val (v ) _mm_loadu_ps((const float*)Bp_val(v))
35
+ #define Vec128_vald (v ) _mm_loadu_pd((const double*)Bp_val(v))
36
+ #define Vec128_vali (v ) _mm_loadu_si128((const __m128i*)Bp_val(v))
37
+ #define Store_vec128_val (v ,x ) _mm_storeu_ps((float*)Bp_val(v), x)
38
+ #define Store_vec128_vald (v ,x ) _mm_storeu_pd((double*)Bp_val(v), x)
39
+ #define Store_vec128_vali (v ,x ) _mm_storeu_si128((__m128i*)Bp_val(v), x)
40
+
41
+ CAMLextern value caml_copy_vec128 (__m128 );
42
+ CAMLextern value caml_copy_vec128i (__m128i );
43
+ CAMLextern value caml_copy_vec128d (__m128d );
44
+ #endif
45
+
46
+ #endif /* CAML_SIMD_H */
Original file line number Diff line number Diff line change
1
+ /**************************************************************************/
2
+ /* */
3
+ /* OCaml */
4
+ /* */
5
+ /* Max Slater, Jane Street */
6
+ /* */
7
+ /* Copyright 2023 Jane Street Group LLC */
8
+ /* */
9
+ /* All rights reserved. This file is distributed under the terms of */
10
+ /* the GNU Lesser General Public License version 2.1, with the */
11
+ /* special exception on linking described in the file LICENSE. */
12
+ /* */
13
+ /**************************************************************************/
14
+
15
+ #define CAML_INTERNALS
16
+
17
+ #include "caml/alloc.h"
18
+ #include "caml/simd.h"
19
+
20
+ #ifdef ARCH_SSE2
21
+
22
+ CAMLexport value caml_copy_vec128 (__m128 v ) {
23
+ value res = caml_alloc_small (2 , Abstract_tag );
24
+ Store_vec128_val (res , v );
25
+ return res ;
26
+ }
27
+
28
+ CAMLexport value caml_copy_vec128i (__m128i v ) {
29
+ value res = caml_alloc_small (2 , Abstract_tag );
30
+ Store_vec128_vali (res , v );
31
+ return res ;
32
+ }
33
+
34
+ CAMLexport value caml_copy_vec128d (__m128d v ) {
35
+ value res = caml_alloc_small (2 , Abstract_tag );
36
+ Store_vec128_vald (res , v );
37
+ return res ;
38
+ }
39
+
40
+ #endif
You can’t perform that action at this time.
0 commit comments