[PATCH] [lld][Driver] Parallelize reading initial object files.

Michael Spencer bigcheesegs at gmail.com
Fri Apr 12 16:02:27 PDT 2013



================
Comment at: lib/Driver/Driver.cpp:47
@@ +46,3 @@
+  size_t index = 0;
+  std::atomic<bool> fail(false);
+  TaskGroup tg;
----------------
Shankar Kalpathi Easwaran wrote:
> Michael Spencer wrote:
> > Shankar Kalpathi Easwaran wrote:
> > > Why you want this to be atomic bool ? because you are only setting the value to be true and the check/return is done only after all the threads have got synced ? 
> > > 
> > > Also it would be essential to check if there was a failure reading one of the files before reading the next set of files.
> > > 
> > > For example:
> > > 
> > > Say thread concurrency = 2
> > > 
> > > TG created 2 threads and there were 4 files
> > > 
> > > Say there was an error reading file 1 (or) file 2. You could stop file 3/4 from being read.
> > It has to be atomic because it could be written from multiple threads.
> > 
> > I don't see why it's essential to early exit the other tasks. It is indeed possible though. Just check the value of fail.
> But all threads would write only a value true. Atomic would be needed only if one thread is writing true and other false, and you need to sync between them right ?
> 
> Say that 3.o and 4.o were very huge files. Linker is going to anyways exit with an error, I see no point of reading 3.o / 4.o.
> [intro.multithreaded] 4 Two expression evaluations conflict if one of them modifies a memory location (1.7) and the other one accesses or modifies the same memory location.
>
> [intro.multithreaded] 21 The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior.

Thus synchronization is required.

And yes, early exit is desirable.


http://llvm-reviews.chandlerc.com/D664



More information about the llvm-commits mailing list