-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvutil_dispatch.cc
More file actions
99 lines (83 loc) · 4.51 KB
/
envutil_dispatch.cc
File metadata and controls
99 lines (83 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/************************************************************************/
/* */
/* utility to convert and extract images from 360 degree environments */
/* */
/* Copyright 2024 by Kay F. Jahnke */
/* */
/* The git repository for this software is at */
/* */
/* https://github.com/kfjahnke/envutil */
/* */
/* Please direct questions, bug reports, and contributions to */
/* */
/* kfjahnke+envutil@gmail.com */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
// this file handles the dispatch to ISA-specific code. This only makes
// sense for code which benefits from SIMD, the remainder of the program,
// which deals with I/O and arguments, can be compiled with a single
// common-denominator ISA.
#include "envutil_dispatch.h"
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "envutil_dispatch.cc"
#include <hwy/foreach_target.h>
#include <hwy/highway.h>
HWY_BEFORE_NAMESPACE() ;
namespace project
{
namespace HWY_NAMESPACE
{
// there isn't any payload code in this file - the implementations
// of the ISA-specific derived 'dispatch' classes is coded in
// envutil_payload.cc. Since all we ever 'get to see' in the part
// of the code which obtains and uses dispatching are pointers to
// dispatch_base, we needn't declare the derived class 'dispatch'.
// _get_dispatch is declared here, because we'll use HWY_EXPORT
// and HWY_DYNAMIC_DISPATCH in this file
const dispatch_base * const _get_dispatch() ;
} ;
} ;
HWY_AFTER_NAMESPACE() ;
#if HWY_ONCE
namespace project
{
// we're using highway's foreach_target mechanism. To get access to the
// SIMD-ISA-specific variant of _get_dispatch (in project::HWY_NAMESPACE)
// we use the HWY_EXPORT macro:
HWY_EXPORT ( _get_dispatch ) ;
// now we can code get_dispatch: it simply uses HWY_DYNAMIC_DISPATCH
// to pick the SIMD-ISA-specific _get_dispatch variant, which in turn
// yields the desired dispatch_base pointer.
// The main program calls 'get_dispatch' and receives a dispatch_base
// pointer, which can be used to route to ISA-specific code best suited
// for the CPU running the code:
// auto dp = get_dispatch() ;
// dp->payload ( ... ) ;
const dispatch_base * const get_dispatch()
{
return HWY_DYNAMIC_DISPATCH ( _get_dispatch ) () ;
}
} ;
#endif