[PATCH] [Core] Add parallel infrastructure to lld.

Shankar Kalpathi Easwaran shankarke at gmail.com
Tue Apr 9 16:45:42 PDT 2013



================
Comment at: include/lld/Core/Parallel.h:47-50
@@ +46,6 @@
+
+  void dec() {
+    if (--_count == 0)
+      _cond.notify_all();
+  }
+
----------------
Michael Spencer wrote:
> Shankar Kalpathi Easwaran wrote:
> > you might want to add a else case to assert probably.
> There's nothing to assert here.
what I meant was if the latch was decremented twice. you could catch that error.

================
Comment at: include/lld/Core/Parallel.h:79
@@ +78,3 @@
+      }
+      work();
+    }).detach();
----------------
Michael Spencer wrote:
> Shankar Kalpathi Easwaran wrote:
> > It might be good to add a name to the task, for tracing purposes.
> Which task?
any task that the thread pool would manage, for example : when you try to add tasks that would read input files parallelly in lld, you could add the name of the file to it, so that you know when the thread starts processing the work.

================
Comment at: include/lld/Core/Parallel.h:97
@@ +96,3 @@
+private:
+  void work() {
+    while (true) {
----------------
Michael Spencer wrote:
> Shankar Kalpathi Easwaran wrote:
> > This could return an ErrorOr to indicate success/failure of this thread.
> It can't fail. And what would look at the return value?
I thought the task that was scheduled to execute in this thread, could fail and the whole process has to be stopped.

For example : you tried to parse all the files in lld parallelly and one of the files was a bad file, you might want to return that failure immediately from the thread and stop everything else.

================
Comment at: include/lld/Core/Parallel.h:108
@@ +107,3 @@
+      lock.unlock();
+      task();
+    }
----------------
Michael Spencer wrote:
> Shankar Kalpathi Easwaran wrote:
> > it would be nice to get the task return status and check for success/failure and set the stop field.
> Task returns void.
Ok. I was thinking if Tasks are made to return an ErrorOr/bool, you could get the return value of task and stop other threads on failure.


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



More information about the llvm-commits mailing list