Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] High-Level (Coase grain) parallelization with ONNXParallelOp and ONNXForkOp based on OpenMP #2756

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

imaihal
Copy link
Collaborator

@imaihal imaihal commented Mar 15, 2024

This PR replaces PR #2681

This PR enables to run set of ONNX operations in parallel by creating threads using OpenMP dialects. (Previous PR #2681 used async dialect) To realize it, this PR provides new ONNX operations (in onnx-mlir) to create threads; ONNXParallelOP to specify parallel region and ONNXForkOp to specify operations for each thread. OpenMP operations are used in their lowering.

This PR includes new operations and their lowering pass. Rewriting ONNX model for inserting the new operations is not included.

image
  • Input ONNX operations
%Y0, %Y1 = ONNX.Parallel{
   %Y0 = ONNX.Fork () -> tensor<>{
      // ONNX operations

      onnx.yield %Y

   }
   %Y1 = ONNX.Fork () -> tensor<>{
      // ONNX operations

      onnx.yield %Y

  }
   onnx.yield %Y0, %Y1

}
  • After lowering to Krnl
%loop0 = krnl.define_loops
   krnl.parallel(%loop0) : !krnl.loop
   krnl.iterate(%loop0) with (%loop0 -> %arg2 = 0 to 2){
      %idx0 = krnl.get_induction_var_value(%loop0) : (!krnl.loop) -> (index)
      %0 = arith.cmpi eq, %idx0, 0 : index
      scf.if %0 {
         // KrnlIR and ZLowIR for the ONNX operations (Thread 0)
      }
      %1 = arith.cmpi eq, %i, 1 : index
      scf.if  %1 {
         // KrnlIR and ZLowIR for the ONNX operations (Thread 1)
      }
 } // krnl.iterate

Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
imaihal and others added 5 commits May 27, 2024 06:57
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Co-authored-by: Yasushi Negishi <negishi@jp.ibm.com>
Signed-off-by: Haruki Imai <imaihal@jp.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant