Index: unittests/ExecutionEngine/Orc/LLJITTest.cpp =================================================================== --- unittests/ExecutionEngine/Orc/LLJITTest.cpp +++ unittests/ExecutionEngine/Orc/LLJITTest.cpp @@ -128,7 +128,7 @@ JITEvaluatedSymbol BarSym = cantFail(Jit->lookup(Extra1, "bar")); EXPECT_EQ(1, Exec(BarSym)); - // Allow buz to resolve foo and bar from the other dylibs: + // Allow buz to resolve foo and bar from the other dylibs. Extra2.addToSearchOrder(Main); Extra2.addToSearchOrder(Extra1); @@ -150,9 +150,9 @@ for (size_t i = 0; i < 3; i++) cantFail(Jit->addIRModule(parseIR(Bs[i], E, Cs[i]))); - // Dispatch compile job to different threads. + // Dispatch compile jobs to different threads. std::vector Ms; - static constexpr size_t MaxMaterializerThreads = 3; + static constexpr size_t MaxMaterializerThreads = 4; Ms.reserve(MaxMaterializerThreads); ES.setDispatchMaterialization( @@ -165,6 +165,18 @@ SMU->doMaterialize(JD); }); }); + + /* + // FIXME: Trying to run this before the other functions always causes a + // deadlock. + Ts.emplace_back([&Jit]() { + JITEvaluatedSymbol BuzSym = cantFail(Jit->lookup("buz")); + EXPECT_EQ(2, Exec(BuzSym)); // Automatically waits for materializer. + }); + + JoinAll(Ts); + JoinAll(Ms); // FIXME: Ideally this happened in the individual runner threads. + */ // Run functions in different threads. Ts.emplace_back([&Jit]() { @@ -179,15 +191,15 @@ // FIXME: Lookup for "buz" can't run in parallel. JoinAll(Ts); - JoinAll(Ms); + JoinAll(Ms); // This should happen in the above runner threads. Ts.emplace_back([&Jit]() { JITEvaluatedSymbol BuzSym = cantFail(Jit->lookup("buz")); EXPECT_EQ(2, Exec(BuzSym)); // Automatically waits for materializer. }); - + JoinAll(Ts); - JoinAll(Ms); + JoinAll(Ms); // FIXME: Ideally this happened in the individual runner threads. } //===----------------------------------------------------------------------===// @@ -211,9 +223,9 @@ for (size_t i = 0; i < 3; i++) cantFail(Jit->addIRModule(*Ds[i], parseIR(Bs[i], E, Cs[i]))); - // Dispatch compile job to different threads. + // Dispatch compile jobs to different threads. std::vector Ms; - static constexpr size_t MaxMaterializerThreads = 3; + static constexpr size_t MaxMaterializerThreads = 4; // one more than necessary Ms.reserve(MaxMaterializerThreads); ES.setDispatchMaterialization( @@ -227,6 +239,22 @@ }); }); + // Allow buz to resolve foo and bar from the other dylibs. + Extra2.addToSearchOrder(Main); + Extra2.addToSearchOrder(Extra1); + + /* + // FIXME: Trying to run this before the other functions always causes a + // deadlock. + Ts.emplace_back([&]() { + JITEvaluatedSymbol BuzSym = cantFail(Jit->lookup(Extra2, "buz")); + EXPECT_EQ(2, Exec(BuzSym)); // Automatically waits for materializer. + }); + + JoinAll(Ts); + JoinAll(Ms); // FIXME: Ideally this happened in the individual runner threads. + */ + // Run functions in different threads. Ts.emplace_back([&]() { JITEvaluatedSymbol FooSym = cantFail(Jit->lookup("foo")); @@ -238,19 +266,12 @@ EXPECT_EQ(1, Exec(BarSym)); // Automatically waits for materializer. }); - // FIXME: Lookup for "buz" can't run in parallel. - JoinAll(Ts); - JoinAll(Ms); - - // Allow buz to resolve foo and bar from the other dylibs. - Extra2.addToSearchOrder(Main); - Extra2.addToSearchOrder(Extra1); - + // Lookup for "buz" works in parallel here even without a barrier. Ts.emplace_back([&]() { JITEvaluatedSymbol BuzSym = cantFail(Jit->lookup(Extra2, "buz")); EXPECT_EQ(2, Exec(BuzSym)); // Automatically waits for materializer. }); JoinAll(Ts); - JoinAll(Ms); + JoinAll(Ms); // FIXME: Ideally this happened in the individual runner threads. }