Revisão | b7b45c1d2af2dd18e0d703faafe62a1bfb69948a (tree) |
---|---|
Hora | 2013-08-06 19:26:03 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring MallocerFreer::AddCurrentMalloced to speed up. #31814
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1460 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -95,13 +95,19 @@ void MallocerFreer::DeleteInstance(){ | ||
95 | 95 | } |
96 | 96 | |
97 | 97 | void MallocerFreer::AddCurrentMalloced(double amount){ |
98 | -#pragma omp critical | |
99 | - { | |
100 | - MallocerFreer::currentMalloced += amount; | |
101 | - if(0 < amount && MallocerFreer::maxMalloced < MallocerFreer::currentMalloced){ | |
102 | - MallocerFreer::maxMalloced = MallocerFreer::currentMalloced; | |
103 | - } | |
104 | - } | |
98 | + #pragma omp atomic | |
99 | + MallocerFreer::currentMalloced += amount; | |
100 | + if(0 < amount){ | |
101 | + #pragma omp flush(MallocerFreer::maxMalloced, MallocerFreer::currentMalloced) | |
102 | + if(MallocerFreer::maxMalloced < MallocerFreer::currentMalloced){ | |
103 | + #pragma omp critical | |
104 | + { | |
105 | + if(MallocerFreer::maxMalloced < MallocerFreer::currentMalloced){ | |
106 | + MallocerFreer::maxMalloced = MallocerFreer::currentMalloced; | |
107 | + } | |
108 | + } | |
109 | + } | |
110 | + } | |
105 | 111 | } |
106 | 112 | |
107 | 113 | } |