Skip to content

Commit 34e1c54

Browse files
committed
GPU: allow standalone benchmark to work on macOS with Metal
1 parent c08e329 commit 34e1c54

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎GPU/GPUTracking/CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ if(CPUDEVICE_ENABLED)
513513
endif()
514514

515515
if(ALIGPU_BUILD_TYPE STREQUAL "O2" OR ALIGPU_BUILD_TYPE STREQUAL "Standalone")
516-
if(NOT ${CMAKE_SYSTEM} MATCHES Darwin)
517-
add_subdirectory(Standalone/Benchmark)
518-
endif()
516+
add_subdirectory(Standalone/Benchmark)
519517
endif()
520518

521519
if(GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_GPU})

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ AddOption(keepAllMemory, bool, false, "", 0, "Allocate all memory on both device
348348
AddOption(keepDisplayMemory, bool, false, "", 0, "Like keepAllMemory, but only for memory required for event display")
349349
AddOption(disableMemoryReuse, bool, false, "", 0, "Disable memory reusage (for debugging only)")
350350
AddOption(memoryAllocationStrategy, int8_t, 0, "", 0, "Memory Allocation Strategy (0 = auto, 1 = individual allocations, 2 = single global allocation)")
351-
AddOption(forceMemoryPoolSize, uint64_t, 1, "memSize", 0, "Force size of allocated GPU / page locked host memory (0 = disable, 1 / 2 = auto, other values set the size of the memory pool)", min(0ul))
352-
AddOption(forceHostMemoryPoolSize, uint64_t, 0, "hostMemSize", 0, "Force size of allocated host page locked host memory (overriding memSize)", min(0ul))
351+
AddOption(forceMemoryPoolSize, uint64_t, 1, "memSize", 0, "Force size of allocated GPU / page locked host memory (0 = disable, 1 / 2 = auto, other values set the size of the memory pool)", min(uint64_t(0)))
352+
AddOption(forceHostMemoryPoolSize, uint64_t, 0, "hostMemSize", 0, "Force size of allocated host page locked host memory (overriding memSize)", min(uint64_t(0)))
353353
AddOption(memoryScalingFactor, float, 1.f, "", 0, "Factor to apply to all memory scalers")
354354
AddOption(memoryScalingFuzz, uint64_t, 0, "", 0, "Fuzz the memoryScalingFactor (0 disable, 1 enable, >1 set seed", def(1))
355355
AddOption(tpcInputWithClusterRejection, uint8_t, 0, "", 0, "Indicate whether the TPC input is CTF data with cluster rejection, to tune buffer estimations")

‎GPU/GPUTracking/Definitions/GPUSettingsListStandalone.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ EndConfig()
4747
BeginConfig(GPUSettingsStandalone, configStandalone)
4848
AddOption(runGPU, uint8_t, 1, "", 'g', "Use GPU for processing", message("GPU processing enabled"), set(2))
4949
AddOptionSet(runGPU, uint8_t, 0, "", 'c', "Use CPU for processing", message("CPU enabled"))
50-
AddOption(gpuType, std::string, "AUTO", "", 0, "GPU type (CUDA / HIP / OCL / CPUDEVICE) or CPU or AUTO")
50+
AddOption(gpuType, std::string, "AUTO", "", 0, "GPU type (CUDA / HIP / OCL / METAL / CPUDEVICE) or CPU or AUTO")
5151
AddOption(runGPUforce, bool, true, "", 0, "Force usage of the specified GPU device type, no CPU fallback")
5252
AddOption(promptOnExit, bool, false, "", 0, "Prompt for keypress before exiting")
5353
AddOption(continueOnError, bool, false, "", 0, "Continue processing after an error")
@@ -64,8 +64,8 @@ AddOption(eventDisplay, int32_t, 0, "display", 'd', "Show standalone event displ
6464
AddOption(eventGenerator, bool, false, "", 0, "Run event generator")
6565
AddOption(cont, bool, false, "", 0, "Process continuous timeframe data, even if input is triggered")
6666
AddOption(setMaxTimeBin, int32_t, -2, "", 0, "maximum time bin of continuous data, 0 for triggered events, -1 for automatic continuous mode, -2 for automatic continuous / triggered")
67-
AddOption(outputcontrolmem, uint64_t, 0, "outputMemory", 0, "Use predefined output buffer of this size", min(0ul), message("Using %s bytes as output memory"))
68-
AddOption(inputcontrolmem, uint64_t, 0, "inputMemory", 0, "Use predefined input buffer of this size", min(0ul), message("Using %s bytes as input memory"))
67+
AddOption(outputcontrolmem, uint64_t, 0, "outputMemory", 0, "Use predefined output buffer of this size", min(uint64_t(0)), message("Using %s bytes as output memory"))
68+
AddOption(inputcontrolmem, uint64_t, 0, "inputMemory", 0, "Use predefined input buffer of this size", min(uint64_t(0)), message("Using %s bytes as input memory"))
6969
AddOption(cpuAffinity, int32_t, -1, "", 0, "Pin CPU affinity to this CPU core", min(-1))
7070
AddOption(fifoScheduler, bool, false, "", 0, "Use FIFO realtime scheduler", message("Setting FIFO scheduler: %s"))
7171
AddOption(fpe, int8_t, -1, "", 0, "Trap on floating point exceptions (-1 = if no ffast-math)")

‎GPU/GPUTracking/Standalone/Benchmark/standalone.cxx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ int32_t ReadConfiguration(int argc, char** argv)
124124
setlocale(LC_ALL, "en_US.utf-8");
125125
setlocale(LC_NUMERIC, "en_US.utf-8");
126126
if (configStandalone.cpuAffinity != -1) {
127+
#ifdef __linux__
127128
cpu_set_t mask;
128129
CPU_ZERO(&mask);
129130
CPU_SET(configStandalone.cpuAffinity, &mask);
@@ -133,8 +134,13 @@ int32_t ReadConfiguration(int argc, char** argv)
133134
printf("Error setting CPU affinity\n");
134135
return 1;
135136
}
137+
#else
138+
printf("CPU affinity not supported on this platform\n");
139+
return 1;
140+
#endif
136141
}
137142
if (configStandalone.fifoScheduler) {
143+
#ifdef __linux__
138144
printf("Setting FIFO scheduler\n");
139145
sched_param param;
140146
sched_getparam(0, &param);
@@ -143,13 +149,21 @@ int32_t ReadConfiguration(int argc, char** argv)
143149
printf("Error setting scheduler\n");
144150
return 1;
145151
}
152+
#else
153+
printf("FIFO scheduler not supported on this platform\n");
154+
return 1;
155+
#endif
146156
}
147157
#ifdef __FAST_MATH__
148158
if (configStandalone.fpe == 1) {
149159
#else
150160
if (configStandalone.fpe) {
151161
#endif
162+
#ifdef __linux__
152163
feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
164+
#else
165+
printf("Trapping floating point exceptions not supported on this platform\n");
166+
#endif
153167
}
154168
bool detMode = false, noFTZMode = false;
155169
#ifdef GPUCA_DETERMINISTIC_MODE
@@ -1021,7 +1035,9 @@ int32_t main(int argc, char** argv)
10211035

10221036
#ifndef _WIN32
10231037
if (configStandalone.proc.runQA && configStandalone.fpe) {
1038+
#ifdef __linux__
10241039
fedisableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
1040+
#endif
10251041
}
10261042
#endif
10271043

0 commit comments

Comments
 (0)