Skip to content

Remove Double Copies from Device to Host and Host to Pointer #18

Description

@Fuad-HH

For example, we could directly copy to an unmanaged kokkos view that is created using the pointer:

readOH2csg/src/capi.cpp

Lines 54 to 86 in aa6b922

// copy edge coefficients to output array
auto host_edge_coefficients =
Kokkos::create_mirror_view(edge_coefficients_view);
Kokkos::deep_copy(host_edge_coefficients, edge_coefficients_view);
for (int edge = 0; edge < mesh->nedges(); ++edge) {
for (int i = 0; i < 6; ++i) {
edge_coefficients[edge * 6 + i] = host_edge_coefficients(edge, i);
}
}
// copy edge types to output array
auto host_edge_types = Kokkos::create_mirror_view(edge_types_v);
Kokkos::deep_copy(host_edge_types, edge_types_v);
for (int edge_id = 0; edge_id < host_edge_types.extent(0); ++edge_id) {
edge_types[edge_id] = host_edge_types[edge_id];
}
// copy boundary edge ids to output array
auto host_boundary_edge_ids_with_sign =
Omega_h::HostRead<Omega_h::LO>(boundary_edges_ids_with_sign);
for (int i = 0; i < boundary_edges_ids_with_sign.size(); ++i) {
boundary_edges[i] = host_boundary_edge_ids_with_sign[i];
}
// copy face connectivity to output array
auto host_face_connectivity =
Kokkos::create_mirror_view(face_connectivity_view);
Kokkos::deep_copy(host_face_connectivity, face_connectivity_view);
for (int face = 0; face < mesh->nfaces(); ++face) {
for (int i = 0; i < 6; ++i) {
face_connectivity[face * 6 + i] = host_face_connectivity(face, i);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions