Skip to content

Commit 243279a

Browse files
committed
GPU Standalone: unify duplicate denormal code in standalone benchmark
1 parent 1c4e4a6 commit 243279a

File tree

2 files changed

+25
-38
lines changed

2 files changed

+25
-38
lines changed

GPU/GPUTracking/Standalone/Benchmark/standalone.cxx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
#include "GPUTPCGMMergedTrack.h"
5454
#include "GPUSettings.h"
5555
#include <vector>
56-
#if not(defined(__ARM_NEON) or defined(__aarch64__)) // ARM doesn't have SSE
57-
#include <xmmintrin.h>
58-
#endif
5956

6057
#include "GPUO2DataTypes.h"
6158
#include "GPUChainITS.h"
@@ -85,23 +82,6 @@ std::atomic<uint32_t> nIteration, nIterationEnd;
8582
std::vector<GPUTrackingInOutPointers> ioPtrEvents;
8683
std::vector<GPUChainTracking::InOutMemory> ioMemEvents;
8784

88-
void SetCPUAndOSSettings()
89-
{
90-
#if not(defined(__ARM_NEON) or defined(__aarch64__)) // ARM doesn't have SSE
91-
#ifdef FE_DFL_DISABLE_SSE_DENORMS_ENV // Flush and load denormals to zero in any case
92-
fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV);
93-
#else
94-
#ifndef _MM_FLUSH_ZERO_ON
95-
#define _MM_FLUSH_ZERO_ON 0x8000
96-
#endif
97-
#ifndef _MM_DENORMALS_ZERO_ON
98-
#define _MM_DENORMALS_ZERO_ON 0x0040
99-
#endif
100-
_mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON));
101-
#endif
102-
#endif // ARM
103-
}
104-
10585
int32_t ReadConfiguration(int argc, char** argv)
10686
{
10787
int32_t qcRet = qConfigParse(argc, (const char**)argv);
@@ -740,8 +720,6 @@ int32_t main(int argc, char** argv)
740720
{
741721
std::unique_ptr<GPUReconstruction> recUnique, recUniqueAsync, recUniquePipeline;
742722

743-
SetCPUAndOSSettings();
744-
745723
if (ReadConfiguration(argc, argv)) {
746724
return 1;
747725
}

GPU/GPUTracking/utils/qmaths_helpers.h

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,33 @@
1515
#ifndef QMATH_HELPERS_H
1616
#define QMATH_HELPERS_H
1717

18-
#if defined __has_include
19-
#if __has_include(<xmmintrin.h>) && __has_include(<pmmintrin.h>)
20-
#include <xmmintrin.h>
21-
#include <pmmintrin.h>
22-
#if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON)
18+
#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include(<xmmintrin.h>) // clang-format off
19+
#include <xmmintrin.h>
20+
#if __has_include(<pmmintrin.h>)
21+
#include <pmmintrin.h>
22+
#endif
23+
#elif __has_include(<cfenv>)
24+
#include <cfenv>
25+
#endif
26+
2327
static void disable_denormals()
2428
{
25-
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
26-
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
29+
#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include(<xmmintrin.h>) // clang-format off
30+
#if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON)
31+
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
32+
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
33+
#else
34+
#ifndef _MM_FLUSH_ZERO_ON
35+
#define _MM_FLUSH_ZERO_ON 0x8000
36+
#endif
37+
#ifndef _MM_DENORMALS_ZERO_ON
38+
#define _MM_DENORMALS_ZERO_ON 0x0040
39+
#endif
40+
_mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON));
41+
#endif
42+
#elif __has_include(<cfenv>) && defined(FE_DFL_DISABLE_SSE_DENORMS_ENV)
43+
fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV);
44+
#endif // clang-format on
2745
}
28-
#define XMM_HAS_DENORMAL_DEACTIVATE
29-
#endif
30-
#endif
31-
#endif
32-
#ifdef XMM_HAS_DENORMAL_DEACTIVATE
33-
#undef XMM_HAS_DENORMAL_DEACTIVATE
34-
#else
35-
static void disable_denormals() {}
36-
#endif
3746

3847
#endif

0 commit comments

Comments
 (0)