This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Do not start threads in AsyncRuntime
ClosedPublic

Authored by ezhulenev on Oct 22 2020, 8:24 AM.

Details

Summary

pthreads is not enabled for all builds by default

Diff Detail

Event Timeline

ezhulenev created this revision.Oct 22 2020, 8:24 AM
ezhulenev requested review of this revision.Oct 22 2020, 8:24 AM
jpienaar accepted this revision.Oct 22 2020, 8:26 AM

Thanks

This revision is now accepted and ready to land.Oct 22 2020, 8:26 AM
This revision was automatically updated to reflect the committed changes.
mehdi_amini added inline comments.Oct 22 2020, 9:15 AM
mlir/lib/ExecutionEngine/AsyncRuntime.cpp
62

Can we do:

#if LLVM_ENABLE_THREADS != 0
  std::thread thread([handle, resume]() { (*resume)(handle); });
#else
  (*resume)(handle);
#endif
ezhulenev added inline comments.Oct 22 2020, 9:20 AM
mlir/lib/ExecutionEngine/AsyncRuntime.cpp
62

Did have much time to fix this issue, but it seems that LLVM_ENABLE_THREADS != enabled pthreads for some reason. Also internally we have LLVM_ENABLE_THREADS=0 (or undefined) but pthreads are enabled.

mehdi_amini added inline comments.Oct 22 2020, 12:43 PM
mlir/lib/ExecutionEngine/AsyncRuntime.cpp
62

LLVM is using std::thread in other places guarded this way I believe, can you elaborate on what was the reason you removed it here?
(the revision does not provide the info right now)