annotate OrthancStone/Sources/Toolbox/SimdIncludes.h @ 2068:22a83fb9dd23 deep-learning

added AlignedMatrix and TimerLogger
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 May 2023 17:30:52 +0200
parents
children 5956d7357098
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2068
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #if defined(__EMSCRIPTEN__)
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 # include <emscripten.h>
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # include <wasm_simd128.h>
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #else
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 # include <immintrin.h> // portable to all x86 compilers
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #endif
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #if __AVX2__ == 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 # define ORTHANC_HAS_AVX2 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 # define ORTHANC_HAS_SSE2 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # define ORTHANC_HAS_WASM_SIMD 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 # define ORTHANC_MEMORY_ALIGNMENT 32
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #elif __SSE2__ == 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 # define ORTHANC_HAS_AVX2 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 # define ORTHANC_HAS_SSE2 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 # define ORTHANC_HAS_WASM_SIMD 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 # define ORTHANC_MEMORY_ALIGNMENT 16
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #elif defined(__EMSCRIPTEN__)
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 # define ORTHANC_HAS_AVX2 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 # define ORTHANC_HAS_SSE2 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 # define ORTHANC_HAS_WASM_SIMD 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 # define ORTHANC_MEMORY_ALIGNMENT 16
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #elif defined(_MSC_VER)
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 # if _M_IX86_FP >= 2 // https://stackoverflow.com/a/18563988
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 # define ORTHANC_HAS_AVX2 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 # define ORTHANC_HAS_SSE2 0
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 # define ORTHANC_HAS_WASM_SIMD 1
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 # define ORTHANC_MEMORY_ALIGNMENT 16
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 # endif
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 #else
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 # define ORTHANC_MEMORY_ALIGNMENT 8
22a83fb9dd23 added AlignedMatrix and TimerLogger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 #endif