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

feat: add side-effect to jit_call #464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: add side-effect to jit_call #464

wants to merge 1 commit into from

Conversation

avik-pal
Copy link
Collaborator

Only the side_effect attr part from #425

@avik-pal
Copy link
Collaborator Author

cc @mofeing this should unblock you

@mofeing
Copy link
Collaborator

mofeing commented Mar 11, 2025

great! thanks @avik-pal

Copy link
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you doubole check that a side effecting op isn't removed by canonicalize. we may need to remove the pure marking (and add custom side effects, cc @ftynse for pointers on)

@mofeing
Copy link
Collaborator

mofeing commented Mar 13, 2025

can you doubole check that a side effecting op isn't removed by canonicalize.

@avik-pal if you need some real MLIR for testing this, you can use the MLIR of calling MPI.Barrier

julia> @code_hlo optimize=false MPI.Barrier(MPI.COMM_WORLD)
module @reactant_Barrier attributes {mhlo.num_partitions = 1 : i64, mhlo.num_replicas = 1 : i64} {
  llvm.mlir.global external constant @MPI_COMM_WORLD() {addr_space = 0 : i32} : !llvm.ptr
  llvm.func @MPI_Barrier(!llvm.ptr) -> i32
  func.func @enzymexla_wrapper_MPI_Barrier() {
    %0 = llvm.mlir.addressof @MPI_COMM_WORLD : !llvm.ptr
    %1 = llvm.call @MPI_Barrier(%0) : (!llvm.ptr) -> i32
    return
  }
  func.func @main() {
    enzymexla.jit_call @enzymexla_wrapper_MPI_Barrier () : () -> ()
    return
  }
}

without side_effect, the jit_call gets deleted

julia> @code_hlo optimize=true MPI.Barrier(MPI.COMM_WORLD)
module @reactant_Barrier attributes {mhlo.num_partitions = 1 : i64, mhlo.num_replicas = 1 : i64} {
  func.func @enzymexla_wrapper_MPI_Barrier() {
    %0 = llvm.mlir.addressof @MPI_COMM_WORLD : !llvm.ptr
    %1 = llvm.call @MPI_Barrier(%0) : (!llvm.ptr) -> i32
    return
  }
  llvm.mlir.global external constant @MPI_COMM_WORLD() {addr_space = 0 : i32, sym_visibility = "private"} : !llvm.ptr
  llvm.func @MPI_Barrier(!llvm.ptr) -> i32 attributes {sym_visibility = "private"}
  func.func @main() {
    return
  }
}

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.

3 participants