Project
Loading...
Searching...
No Matches
GPUMemorySizeScalers.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16#include "GPULogging.h"
17
18#include <random>
19
20using namespace o2::gpu;
21
22void GPUMemorySizeScalers::rescaleMaxMem(size_t newAvailableMemory)
23{
25 double scaleFactor = (double)newAvailableMemory / tmp.availableMemory;
26 if (scaleFactor != 1.) {
27 GPUInfo("Rescaling buffer size limits from %lu to %lu bytes of memory (factor %f)", tmp.availableMemory, newAvailableMemory, scaleFactor);
28 }
29 tpcMaxPeaks = (double)tmp.tpcMaxPeaks * scaleFactor;
30 tpcMaxClusters = (double)tmp.tpcMaxClusters * scaleFactor;
31 tpcMaxStartHits = (double)tmp.tpcMaxStartHits * scaleFactor;
32 tpcMaxRowStartHits = (double)tmp.tpcMaxRowStartHits * scaleFactor;
33 tpcMaxTracklets = (double)tmp.tpcMaxTracklets * scaleFactor;
34 tpcMaxTrackletHits = (double)tmp.tpcMaxTrackletHits * scaleFactor;
35 tpcMaxSectorTracks = (double)tmp.tpcMaxSectorTracks * scaleFactor;
36 tpcMaxSectorTrackHits = (double)tmp.tpcMaxSectorTrackHits * scaleFactor;
37 tpcMaxMergedTracks = (double)tmp.tpcMaxMergedTracks * scaleFactor;
38 tpcMaxMergedTrackHits = (double)tmp.tpcMaxMergedTrackHits * scaleFactor;
39 availableMemory = newAvailableMemory;
40}
41
43{
44 if (!doFuzzing) {
45 return scalingFactor;
46 }
47 static std::uniform_int_distribution<uint32_t> dist(0, 1000000);
48 static std::mt19937 rng;
49 if (fuzzSeed) {
50 rng = std::mt19937(fuzzSeed);
51 fuzzLimit = dist(rng) / 10;
52 fuzzSeed = 0;
53 }
54 if (dist(rng) > fuzzLimit) {
55 return scalingFactor;
56 }
57 return scalingFactor * 0.000001 * dist(rng);
58}
59
61{
62 fuzzSeed = seed;
63 doFuzzing = true;
64}
void rescaleMaxMem(size_t newAvailableMemory)