OLD | NEW |
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 Str << "\n"; | 283 Str << "\n"; |
284 if (Func != nullptr) { | 284 if (Func != nullptr) { |
285 Str << "|" << Name << "|Cfg Memory |" << Func->getTotalMemoryMB() | 285 Str << "|" << Name << "|Cfg Memory |" << Func->getTotalMemoryMB() |
286 << " MB\n"; | 286 << " MB\n"; |
287 Str << "|" << Name << "|Liveness Memory |" << Func->getLivenessMemoryMB() | 287 Str << "|" << Name << "|Liveness Memory |" << Func->getLivenessMemoryMB() |
288 << " MB\n"; | 288 << " MB\n"; |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
| 292 namespace { |
| 293 |
| 294 // By default, wake up the main parser thread when the OptQ gets half empty. |
| 295 static constexpr size_t DefaultOptQWakeupSize = GlobalContext::MaxOptQSize >> 1; |
| 296 |
| 297 } // end of anonymous namespace |
| 298 |
292 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, | 299 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, |
293 ELFStreamer *ELFStr) | 300 ELFStreamer *ELFStr) |
294 : Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(), | 301 : Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(), |
295 StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this), | 302 StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this), |
296 ObjectWriter(), OptQ(/*Sequential=*/getFlags().isSequential(), | 303 ObjectWriter(), |
297 /*MaxSize=*/ | 304 OptQWakeupSize(std::max(DefaultOptQWakeupSize, |
298 getFlags().isParseParallel() | 305 size_t(getFlags().getNumTranslationThreads()))), |
299 ? MaxOptQSize | 306 OptQ(/*Sequential=*/getFlags().isSequential(), |
300 : getFlags().getNumTranslationThreads()), | 307 /*MaxSize=*/ |
| 308 getFlags().isParseParallel() |
| 309 ? MaxOptQSize |
| 310 : getFlags().getNumTranslationThreads()), |
301 // EmitQ is allowed unlimited size. | 311 // EmitQ is allowed unlimited size. |
302 EmitQ(/*Sequential=*/getFlags().isSequential()), | 312 EmitQ(/*Sequential=*/getFlags().isSequential()), |
303 DataLowering(TargetDataLowering::createLowering(this)) { | 313 DataLowering(TargetDataLowering::createLowering(this)) { |
304 assert(OsDump && "OsDump is not defined for GlobalContext"); | 314 assert(OsDump && "OsDump is not defined for GlobalContext"); |
305 assert(OsEmit && "OsEmit is not defined for GlobalContext"); | 315 assert(OsEmit && "OsEmit is not defined for GlobalContext"); |
306 assert(OsError && "OsError is not defined for GlobalContext"); | 316 assert(OsError && "OsError is not defined for GlobalContext"); |
307 // Make sure thread_local fields are properly initialized before any | 317 // Make sure thread_local fields are properly initialized before any |
308 // accesses are made. Do this here instead of at the start of | 318 // accesses are made. Do this here instead of at the start of |
309 // main() so that all clients (e.g. unit tests) can benefit for | 319 // main() so that all clients (e.g. unit tests) can benefit for |
310 // free. | 320 // free. |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 { | 942 { |
933 TimerMarker _(TimerStack::TT_qTransPush, this); | 943 TimerMarker _(TimerStack::TT_qTransPush, this); |
934 OptQ.blockingPush(std::move(Item)); | 944 OptQ.blockingPush(std::move(Item)); |
935 } | 945 } |
936 if (getFlags().isSequential()) | 946 if (getFlags().isSequential()) |
937 translateFunctions(); | 947 translateFunctions(); |
938 } | 948 } |
939 | 949 |
940 std::unique_ptr<OptWorkItem> GlobalContext::optQueueBlockingPop() { | 950 std::unique_ptr<OptWorkItem> GlobalContext::optQueueBlockingPop() { |
941 TimerMarker _(TimerStack::TT_qTransPop, this); | 951 TimerMarker _(TimerStack::TT_qTransPop, this); |
942 return std::unique_ptr<OptWorkItem>(OptQ.blockingPop()); | 952 return OptQ.blockingPop(OptQWakeupSize); |
943 } | 953 } |
944 | 954 |
945 void GlobalContext::emitQueueBlockingPush( | 955 void GlobalContext::emitQueueBlockingPush( |
946 std::unique_ptr<EmitterWorkItem> Item) { | 956 std::unique_ptr<EmitterWorkItem> Item) { |
947 assert(Item); | 957 assert(Item); |
948 { | 958 { |
949 TimerMarker _(TimerStack::TT_qEmitPush, this); | 959 TimerMarker _(TimerStack::TT_qEmitPush, this); |
950 EmitQ.blockingPush(std::move(Item)); | 960 EmitQ.blockingPush(std::move(Item)); |
951 } | 961 } |
952 if (getFlags().isSequential()) | 962 if (getFlags().isSequential()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 void TimerMarker::pushCfg(const Cfg *Func) { | 1039 void TimerMarker::pushCfg(const Cfg *Func) { |
1030 Ctx = Func->getContext(); | 1040 Ctx = Func->getContext(); |
1031 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); | 1041 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); |
1032 if (Active) | 1042 if (Active) |
1033 Ctx->pushTimer(ID, StackID); | 1043 Ctx->pushTimer(ID, StackID); |
1034 } | 1044 } |
1035 | 1045 |
1036 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 1046 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
1037 | 1047 |
1038 } // end of namespace Ice | 1048 } // end of namespace Ice |
OLD | NEW |