Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Issue 870653002: Subzero: Initial implementation of multithreaded translation. (Closed)

Created:
5 years, 11 months ago by Jim Stichnoth
Modified:
5 years, 11 months ago
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Initial implementation of multithreaded translation. Provides a single-producer, multiple-consumer translation queue where the number of translation threads is given by the -threads=N argument. The producer (i.e., bitcode parser) blocks if the queue size is >=N, in order to control the memory footprint. If N=0 (which is the default), execution is purely single-threaded. If N=1, there is a single translation thread running in parallel with the parser thread. "make check" succeeds with the default changed to N=1. Currently emission is also done by the translation thread, which limits scalability since the emit stream has to be locked. Also, since the ELF writer stream is not locked, it won't be safe to use N>1 with the ELF writer. Furthermore, for N>1, emitted function ordering is nondeterministic and needs to be recombobulated. This will all be fixed in a follow-on CL. The -timing option is broken for N>0. This will be fixed in a follow-on CL. Verbose flags are now managed in the Cfg instead of (or in addition to) the GlobalContext, due to the -verbose-focus option which wants to temporarily change the verbose level for a particular function. TargetLowering::emitConstants() and related methods are changed to be static, so that a valid TargetLowering object isn't required. This is because the TargetLowering object wants to hold a valid Cfg, and none really exists after all functions are translated and the constant pool is ready for emission. The Makefile.standalone now has a TSAN=1 option to enable ThreadSanitizer. BUG= none R=jfb@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=fa4efea5413aa993e8e6ba10579e0934d1a3e784

Patch Set 1 #

Patch Set 2 : Cleanup #

Total comments: 47

Patch Set 3 : Code review update #

Patch Set 4 : Fix some work queue issues #

Patch Set 5 : Fix getErrorStatus() usage in BitcodeMunger #

Total comments: 6

Patch Set 6 : Code review changes, continued #

Total comments: 10

Patch Set 7 : Better error code management. Move locked fields around. #

Patch Set 8 : Make CfgQueue::Sequential logic more clear. Move IsEnded field. #

Total comments: 32

Patch Set 9 : Add a TSAN=1 make configuration #

Patch Set 10 : Adjustments to CfgQueue #

Patch Set 11 : clang-format #

Total comments: 10

Patch Set 12 : Enhance error codes. Use a circular buffer under the work queue. #

Total comments: 11

Patch Set 13 : Better circular buffer implementation. Comment changes. #

Patch Set 14 : Rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+551 lines, -280 lines) Patch
M Makefile.standalone View 1 2 3 4 5 6 7 8 3 chunks +11 lines, -2 lines 0 comments Download
M src/IceCfg.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +8 lines, -2 lines 0 comments Download
M src/IceCfg.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 6 chunks +12 lines, -15 lines 0 comments Download
M src/IceCfgNode.cpp View 1 2 3 4 5 5 chunks +8 lines, -8 lines 0 comments Download
M src/IceClFlags.h View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M src/IceConverter.cpp View 1 2 3 4 5 1 chunk +0 lines, -2 lines 0 comments Download
M src/IceDefs.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +45 lines, -0 lines 0 comments Download
M src/IceGlobalContext.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 7 chunks +93 lines, -24 lines 0 comments Download
M src/IceGlobalContext.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +48 lines, -4 lines 0 comments Download
M src/IceInst.cpp View 2 chunks +3 lines, -4 lines 0 comments Download
M src/IceOperand.cpp View 1 chunk +3 lines, -3 lines 0 comments Download
M src/IceRegAlloc.cpp View 3 chunks +3 lines, -4 lines 0 comments Download
M src/IceTargetLowering.h View 1 2 3 4 5 2 chunks +12 lines, -14 lines 0 comments Download
M src/IceTargetLowering.cpp View 1 2 1 chunk +7 lines, -8 lines 0 comments Download
M src/IceTargetLoweringX8632.h View 1 2 3 4 5 2 chunks +11 lines, -10 lines 0 comments Download
M src/IceTargetLoweringX8632.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 7 chunks +79 lines, -76 lines 0 comments Download
M src/IceTranslator.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +11 lines, -21 lines 0 comments Download
M src/IceTranslator.cpp View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +17 lines, -51 lines 0 comments Download
M src/IceUtils.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +127 lines, -0 lines 0 comments Download
M src/PNaClTranslator.h View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M src/PNaClTranslator.cpp View 1 2 3 4 5 6 7 8 9 10 11 10 chunks +8 lines, -11 lines 0 comments Download
M src/llvm2ice.cpp View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +37 lines, -15 lines 0 comments Download
M tests_lit/llvm2ice_tests/nacl-atomic-errors.ll View 1 chunk +1 line, -1 line 0 comments Download
M unittest/BitcodeMunge.cpp View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 29 (1 generated)
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.cpp#newcode155 src/IceGlobalContext.cpp:155: resetStats(); Most of this function was moved from Translator::translateFcn() ...
5 years, 11 months ago (2015-01-22 19:10:29 UTC) #2
Karl
https://codereview.chromium.org/870653002/diff/20001/src/IceTranslator.h File src/IceTranslator.h (left): https://codereview.chromium.org/870653002/diff/20001/src/IceTranslator.h#oldcode86 src/IceTranslator.h:86: std::unique_ptr<Cfg> Func; Nice to see this wart go away! ...
5 years, 11 months ago (2015-01-22 20:41:13 UTC) #3
JF
It would be much better if the verbose change were separate from the multithreading change. ...
5 years, 11 months ago (2015-01-22 20:50:56 UTC) #4
JF
Also, does the current code emit deterministic output when multithreaded? It should at east have ...
5 years, 11 months ago (2015-01-22 21:12:14 UTC) #5
Jim Stichnoth
On 2015/01/22 21:12:14, JF wrote: > Also, does the current code emit deterministic output when ...
5 years, 11 months ago (2015-01-22 21:26:32 UTC) #6
jvoung (off chromium)
Not much to add =) https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.cpp#newcode498 src/IceGlobalContext.cpp:498: return; Could report_fatal_error for ...
5 years, 11 months ago (2015-01-22 23:06:06 UTC) #7
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/20001/src/IceCfg.cpp File src/IceCfg.cpp (right): https://codereview.chromium.org/870653002/diff/20001/src/IceCfg.cpp#newcode49 src/IceCfg.cpp:49: Cfg::~Cfg() { CurrentCfg = nullptr; } On 2015/01/22 20:50:56, ...
5 years, 11 months ago (2015-01-23 07:55:55 UTC) #8
JF
Pre-meeting partial review. https://codereview.chromium.org/870653002/diff/80001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/870653002/diff/80001/src/IceGlobalContext.cpp#newcode135 src/IceGlobalContext.cpp:135: CfgQ(Flags.NumTranslationThreads, (Flags.NumTranslationThreads == 0)), Add /*MaxSize=*/ ...
5 years, 11 months ago (2015-01-23 17:22:43 UTC) #9
jvoung (off chromium)
https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.h#newcode105 src/IceGlobalContext.h:105: std::unique_lock<GlobalLockType> L(Lock); On 2015/01/23 07:55:55, stichnot wrote: > On ...
5 years, 11 months ago (2015-01-23 17:49:09 UTC) #10
JF
https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/20001/src/IceGlobalContext.h#newcode105 src/IceGlobalContext.h:105: std::unique_lock<GlobalLockType> L(Lock); On 2015/01/23 17:49:09, jvoung wrote: > On ...
5 years, 11 months ago (2015-01-23 17:51:02 UTC) #11
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/80001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/870653002/diff/80001/src/IceGlobalContext.cpp#newcode135 src/IceGlobalContext.cpp:135: CfgQ(Flags.NumTranslationThreads, (Flags.NumTranslationThreads == 0)), On 2015/01/23 17:22:43, JF wrote: ...
5 years, 11 months ago (2015-01-23 21:54:02 UTC) #12
JF
https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h#newcode167 src/IceGlobalContext.h:167: alignas(MaxCacheLineSize) bool IsEnded; Move to end with Sequential: it's ...
5 years, 11 months ago (2015-01-23 22:22:11 UTC) #13
jvoung (off chromium)
https://codereview.chromium.org/870653002/diff/100001/src/IceTranslator.h File src/IceTranslator.h (right): https://codereview.chromium.org/870653002/diff/100001/src/IceTranslator.h#newcode71 src/IceTranslator.h:71: // the exit status of the translation. False is ...
5 years, 11 months ago (2015-01-23 22:56:37 UTC) #14
JF
https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h#newcode110 src/IceGlobalContext.h:110: // which the single thread should never wait(). Shouldn't ...
5 years, 11 months ago (2015-01-23 23:01:47 UTC) #15
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/100001/src/IceGlobalContext.h#newcode110 src/IceGlobalContext.h:110: // which the single thread should never wait(). On ...
5 years, 11 months ago (2015-01-25 07:29:39 UTC) #16
Jim Stichnoth
Added a TSAN=1 option to Makefile.standalone to enable ThreadSanitizer. I had to deliberately remove a ...
5 years, 11 months ago (2015-01-25 21:25:31 UTC) #17
JF
OK I took a look at the difficult part of the code. I think we're ...
5 years, 11 months ago (2015-01-25 22:57:01 UTC) #18
Jim Stichnoth
error_code comment still to be addressed. https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h#newcode120 src/IceGlobalContext.h:120: class CfgQueue { ...
5 years, 11 months ago (2015-01-26 04:59:44 UTC) #19
JF
https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h#newcode123 src/IceGlobalContext.h:123: : MaxSize(MaxSize), Sequential(Sequential), IsEnded(false) {} On 2015/01/26 04:59:43, stichnot ...
5 years, 11 months ago (2015-01-26 17:54:51 UTC) #20
JF
https://codereview.chromium.org/870653002/diff/200001/src/IceUtils.h File src/IceUtils.h (right): https://codereview.chromium.org/870653002/diff/200001/src/IceUtils.h#newcode121 src/IceUtils.h:121: return Func; How about this: T *Func = nullptr; ...
5 years, 11 months ago (2015-01-26 18:05:26 UTC) #21
JF
https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h#newcode166 src/IceGlobalContext.h:166: L.unlock(); On 2015/01/26 04:59:43, stichnot wrote: > On 2015/01/25 ...
5 years, 11 months ago (2015-01-26 18:10:40 UTC) #22
JF
https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h File src/IceGlobalContext.h (right): https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.h#newcode412 src/IceGlobalContext.h:412: const VerboseMask VMask; On 2015/01/26 17:54:50, JF wrote: > ...
5 years, 11 months ago (2015-01-26 19:11:49 UTC) #23
Karl
https://codereview.chromium.org/870653002/diff/200001/src/PNaClTranslator.cpp File src/PNaClTranslator.cpp (right): https://codereview.chromium.org/870653002/diff/200001/src/PNaClTranslator.cpp#newcode363 src/PNaClTranslator.cpp:363: std::error_code &ErrorStatus; As per our earlier discussion, This should ...
5 years, 11 months ago (2015-01-26 22:53:47 UTC) #24
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.cpp File src/IceGlobalContext.cpp (right): https://codereview.chromium.org/870653002/diff/140001/src/IceGlobalContext.cpp#newcode174 src/IceGlobalContext.cpp:174: getErrorStatus()->assign(1, std::generic_category()); On 2015/01/25 22:57:00, JF wrote: > Make ...
5 years, 11 months ago (2015-01-27 00:56:18 UTC) #25
JF
A few nits, then LGTM ლ(╹◡╹ლ) https://codereview.chromium.org/870653002/diff/220001/src/IceDefs.h File src/IceDefs.h (right): https://codereview.chromium.org/870653002/diff/220001/src/IceDefs.h#newcode205 src/IceDefs.h:205: ErrorCode() : std::error_code(), ...
5 years, 11 months ago (2015-01-27 01:53:34 UTC) #26
Jim Stichnoth
https://codereview.chromium.org/870653002/diff/220001/src/IceDefs.h File src/IceDefs.h (right): https://codereview.chromium.org/870653002/diff/220001/src/IceDefs.h#newcode205 src/IceDefs.h:205: ErrorCode() : std::error_code(), HasError(false) {} On 2015/01/27 01:53:33, JF ...
5 years, 11 months ago (2015-01-27 05:35:12 UTC) #27
JF
Mucho mas LGTM. https://codereview.chromium.org/870653002/diff/220001/src/IceUtils.h File src/IceUtils.h (right): https://codereview.chromium.org/870653002/diff/220001/src/IceUtils.h#newcode170 src/IceUtils.h:170: size_t size() const { return (Back ...
5 years, 11 months ago (2015-01-27 06:04:36 UTC) #28
Jim Stichnoth
5 years, 11 months ago (2015-01-27 13:06:07 UTC) #29
Message was sent while issue was closed.
Committed patchset #14 (id:260001) manually as
fa4efea5413aa993e8e6ba10579e0934d1a3e784 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698