This is an archive of the discontinued LLVM Phabricator instance.

[mlir] AsyncRuntime: fix concurrency bugs + fix exports in methods definitions
ClosedPublic

Authored by ezhulenev on Nov 23 2020, 11:53 AM.

Details

Summary
  1. Move ThreadPool ownership to the runtime, and wait for the async tasks completion in the destructor.
  2. Remove MLIR_ASYNCRUNTIME_EXPORT from method definitions because they are unnecessary in .cpp files, as only function declarations need to be exported, not their definitions.
  3. Fix concurrency bugs in group emplace and potential use-after-free in token emplace.

Tested internally 10k runs in async.mlir and async-group.mlir.

Fixed: https://bugs.llvm.org/show_bug.cgi?id=48267

Diff Detail

Event Timeline

ezhulenev created this revision.Nov 23 2020, 11:53 AM
ezhulenev requested review of this revision.Nov 23 2020, 11:53 AM
ezhulenev edited the summary of this revision. (Show Details)Nov 23 2020, 11:53 AM
ezhulenev added reviewers: ftynse, mehdi_amini.
ezhulenev edited the summary of this revision. (Show Details)
ezhulenev retitled this revision from [mlir] AsyncRuntime: fix concurrency bugs + exports in methods definitions to [mlir] AsyncRuntime: fix concurrency bugs + fix exports in methods definitions.Nov 23 2020, 12:00 PM

Why the removal for all MLIR_ASYNCRUNTIME_EXPORT? (in general please explain the motivation in commit description: the "why" instead of just the "what").

ezhulenev edited the summary of this revision. (Show Details)Nov 23 2020, 3:32 PM

Why the removal for all MLIR_ASYNCRUNTIME_EXPORT? (in general please explain the motivation in commit description: the "why" instead of just the "what").

That just got out of sync with https://github.com/llvm/llvm-project/commit/6fd9e59e1b3ac15430eccd4011e063605f58039c and reference counting change. Added a motivation.

mehdi_amini accepted this revision.Nov 23 2020, 3:58 PM

OK, in general please keep changes that are conceptually separated in different revision / commits, each with they description.

LGTM.

This revision is now accepted and ready to land.Nov 23 2020, 3:58 PM
rriddle added inline comments.Nov 23 2020, 4:00 PM
mlir/lib/ExecutionEngine/AsyncRuntime.cpp
56

Extra S here and below.

ezhulenev updated this revision to Diff 307290.Nov 24 2020, 2:20 AM

Remove unnecessary addRef/dropRef in async await

ezhulenev updated this revision to Diff 307301.Nov 24 2020, 3:17 AM

Fix pre-merge checks warnings

ezhulenev edited the summary of this revision. (Show Details)Nov 24 2020, 3:23 AM
ezhulenev marked an inline comment as done.Nov 24 2020, 3:26 AM