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

Implement Events #129

Open
bonachea opened this issue Aug 21, 2024 · 0 comments
Open

Implement Events #129

bonachea opened this issue Aug 21, 2024 · 0 comments

Comments

@bonachea
Copy link
Member

These should basically just be a thin wrapper around integer atomics, ie:

type, public :: prif_event_type
  private
  integer(PRIF_ATOMIC_INT_KIND) :: value = 0
end type

! Everything below is UNTESTED PSEUDOCODE

module procedure prif_event_post(image_num, coarray_handle, offset, stat, errmsg, errmsg_alloc)
  call prif_sync_memory(stat, errmsg, errmsg_alloc)
  if (present(stat) && stat) return
  call prif_atomic_add(image_num, coarray_handle, offset, 1, stat)
  if (present(stat) && stat) ... ! set errmsg(_alloc) if present
end procedure 

module procedure prif_event_post_indirect(image_num, event_var_ptr, stat, errmsg, errmsg_alloc)
  ! same as above, but using prif_atomic_add_indirect
end procedure 

module procedure prif_event_query(event_var_ptr, count, stat)
  integer(PRIF_ATOMIC_INT_KIND) :: temp

  call prif_atomic_ref_int_indirect(this_image_world, event_var_ptr, temp, stat)
  if (!(present(stat) && stat)) count = temp
end procedure 

module procedure prif_event_wait(event_var_ptr, until_count, stat, errmsg, errmsg_alloc)
  integer(PRIF_ATOMIC_INT_KIND) :: until_int

  if (present(until_count)) until_int = max(until_count,1)
  else until_int = 1
  do 
     integer(PRIF_ATOMIC_INT_KIND) :: temp

     call prif_atomic_ref_int_indirect(this_image_world, event_var_ptr, temp, stat)
     if (present(stat) && stat) {
        ! set errmsg(_alloc) if present
        return
     }
     if (temp >= until_int) exit
  end do
  call prif_atomic_add_indirect(this_image_world, event_var_ptr, -until_int, stat)  
  if (present(stat) && stat) {
    ! set errmsg(_alloc) if present
    return
  }
  call prif_sync_memory(stat, errmsg, errmsg_alloc)
end procedure 

Where the atomic operations are themselves just thin wrappers around GASNet-EX atomics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant