iree/hal/local/task_queue.c
// Clones a list of semaphores into an |arena| and initializes |out_target_list|
// to reference the newly-cloned data.
Clones a list of semaphores into an |arena| and initializes |out_target_list|
to reference the newly-cloned data.
Clones a list of semaphores into an |arena| and initializes |out_target_list| to reference the newly - cloned data .
static iree_status_t iree_hal_semaphore_list_clone(
    const iree_hal_semaphore_list_t* source_list, iree_arena_allocator_t* arena,
    iree_hal_semaphore_list_t* out_target_list) {
  iree_host_size_t semaphores_size =
      source_list->count * sizeof(out_target_list->semaphores[0]);
  iree_host_size_t payload_values_size =
      source_list->count * sizeof(out_target_list->payload_values[0]);
  iree_host_size_t total_size = semaphores_size + payload_values_size;
  uint8_t* buffer = NULL;
  IREE_RETURN_IF_ERROR(iree_arena_allocate(arena, total_size, (void**)&buffer));
  out_target_list->count = source_list->count;
  out_target_list->semaphores = (iree_hal_semaphore_t**)buffer;
  out_target_list->payload_values = (uint64_t*)(buffer + semaphores_size);
  for (iree_host_size_t i = 0; i < source_list->count; ++i) {
    out_target_list->semaphores[i] = source_list->semaphores[i];
    iree_hal_semaphore_retain(out_target_list->semaphores[i]);
    out_target_list->payload_values[i] = source_list->payload_values[i];
  }
  return iree_ok_status();
}
static iree_status_t iree_hal_semaphore_list_clone ( const iree_hal_semaphore_list_t * source_list , iree_arena_allocator_t * arena , iree_hal_semaphore_list_t * out_target_list ) { iree_host_size_t semaphores_size = source_list -> count * sizeof ( out_target_list -> semaphores [ 0 ] ) ; iree_host_size_t payload_values_size = source_list -> count * sizeof ( out_target_list -> payload_values [ 0 ] ) ; iree_host_size_t total_size = semaphores_size + payload_values_size ; uint8_t * buffer = NULL ; IREE_RETURN_IF_ERROR ( iree_arena_allocate ( arena , total_size , ( void * * ) & buffer ) ) ; out_target_list -> count = source_list -> count ; out_target_list -> semaphores = ( iree_hal_semaphore_t * * ) buffer ; out_target_list -> payload_values = ( uint64_t * ) ( buffer + semaphores_size ) ; for ( iree_host_size_t i = 0 ; i < source_list -> count ; ++ i ) { out_target_list -> semaphores [ i ] = source_list -> semaphores [ i ] ; iree_hal_semaphore_retain ( out_target_list -> semaphores [ i ] ) ; out_target_list -> payload_values [ i ] = source_list -> payload_values [ i ] ; } return iree_ok_status ( ) ; }
Clones a list of semaphores into an |arena| and initializes |out_target_list|
to reference the newly-cloned data.
Clones a list of semaphores into an |arena| and initializes |out_target_list| to reference the newly - cloned data .