Skip to content

Commit 7272e89

Browse files
committed
GPU Standalone: unify duplicate denormal code in standalone benchmark
1 parent d1fcd96 commit 7272e89

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-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: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,31 @@
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)
2318
static void disable_denormals()
2419
{
25-
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
26-
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
20+
#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include(<xmmintrin.h>) // clang-format off
21+
#include <xmmintrin.h>
22+
#if __has_include(<pmmintrin.h>)
23+
#include <pmmintrin.h>
24+
#endif
25+
#if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON)
26+
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
27+
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
28+
#else
29+
#ifndef _MM_FLUSH_ZERO_ON
30+
#define _MM_FLUSH_ZERO_ON 0x8000
31+
#endif
32+
#ifndef _MM_DENORMALS_ZERO_ON
33+
#define _MM_DENORMALS_ZERO_ON 0x0040
34+
#endif
35+
_mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON));
36+
#endif
37+
#elif __has_include(<cfenv>)
38+
#include <cfenv>
39+
#ifdef FE_DFL_DISABLE_SSE_DENORMS_ENV
40+
fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV);
41+
#endif
42+
#endif // clang-format on
2743
}
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
3744

3845
#endif

0 commit comments

Comments
 (0)