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

Passing size==0 to DeepCopy/memcpy/omp_target_memcpy #6273

Merged
merged 4 commits into from
Aug 4, 2023

Conversation

nliber
Copy link
Contributor

@nliber nliber commented Jul 10, 2023

This is to address issue #6034.

This approach is more general in that no work happens with DeepCopy, memcpy or omp_target_memcpy when a zero size is passed to it. This avoids the issue of reading an invalid pointer value.

@nliber nliber changed the base branch from master to develop July 10, 2023 22:45
@nliber nliber marked this pull request as draft July 10, 2023 22:45
@nliber
Copy link
Contributor Author

nliber commented Jul 11, 2023

retest this please

@nliber nliber marked this pull request as ready for review July 12, 2023 22:23
@crtrott
Copy link
Member

crtrott commented Jul 14, 2023

Retest this please.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Please add a test.

dalg24
dalg24 previously requested changes Jul 14, 2023
core/src/HIP/Kokkos_HIP_Instance.cpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_Profiling.cpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_HostSpace_deepcopy.cpp Outdated Show resolved Hide resolved
0-length ranges, as per this comment in
core/src/OpenMPTarget/Kokkos_OpenMPTargetSpace.hpp

      // In the Release and RelWithDebInfo builds, the size of the memcpy should
      // be greater than zero to avoid error.
Removed unnecessary size check in Kokkos_Profiling.cpp
Fixed size check in Kokkos_HostSpace_deepcopy.cpp
Fixed size check in Kokkos_OpenMPTarget_Parallel_Common.hpp
@dalg24 dalg24 dismissed their stale review July 21, 2023 23:00

Issues reported were addressed

@crtrott
Copy link
Member

crtrott commented Aug 1, 2023

@masterleinad Is there anything missing in this test:

TEST(TEST_CATEGORY, view_copy_degenerated) {
Kokkos::View<int*, TEST_EXECSPACE, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
v_um_def_1;
Kokkos::View<int*, TEST_EXECSPACE, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
v_um_1(reinterpret_cast<int*>(-1), 0);
Kokkos::View<int*, TEST_EXECSPACE> v_m_def_1;
Kokkos::View<int*, TEST_EXECSPACE> v_m_1("v_m_1", 0);
Kokkos::View<int*, TEST_EXECSPACE, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
v_um_def_2;
Kokkos::View<int*, TEST_EXECSPACE, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
v_um_2(reinterpret_cast<int*>(-1), 0);
Kokkos::View<int*, TEST_EXECSPACE> v_m_def_2;
Kokkos::View<int*, TEST_EXECSPACE> v_m_2("v_m_2", 0);
Kokkos::deep_copy(v_um_def_1, v_um_def_2);
Kokkos::deep_copy(v_um_def_1, v_um_2);
Kokkos::deep_copy(v_um_def_1, v_m_def_2);
Kokkos::deep_copy(v_um_def_1, v_m_2);
Kokkos::deep_copy(v_um_1, v_um_def_2);
Kokkos::deep_copy(v_um_1, v_um_2);
Kokkos::deep_copy(v_um_1, v_m_def_2);
Kokkos::deep_copy(v_um_1, v_m_2);
Kokkos::deep_copy(v_m_def_1, v_um_def_2);
Kokkos::deep_copy(v_m_def_1, v_um_2);
Kokkos::deep_copy(v_m_def_1, v_m_def_2);
Kokkos::deep_copy(v_m_def_1, v_m_2);
Kokkos::deep_copy(v_m_1, v_um_def_2);
Kokkos::deep_copy(v_m_1, v_um_2);
Kokkos::deep_copy(v_m_1, v_m_def_2);
Kokkos::deep_copy(v_m_1, v_m_2);
}

@crtrott
Copy link
Member

crtrott commented Aug 1, 2023

Retest this please

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@crtrott
Copy link
Member

crtrott commented Aug 2, 2023

Retest this please.

@crtrott
Copy link
Member

crtrott commented Aug 2, 2023

Looks like OpenMPTarget didn't run, I want to see it at least compile since a bunch of OpenMPTarget specific files were touched.

@Rombur
Copy link
Member

Rombur commented Aug 2, 2023

Retest this please

@fnrizzi
Copy link
Contributor

fnrizzi commented Aug 3, 2023

only OpenMPTarget fails, error is:

5: Test command: /var/jenkins/workspace/Kokkos/build/simd/unit_tests/Kokkos_UnitTest_SIMD
35: Test timeout computed to be: 1500
35: [==========] Running 2 tests from 1 test suite.
35: [----------] Global test environment set-up.
35: [----------] 2 tests from simd
35: [ RUN      ] simd.host
35: [       OK ] simd.host (0 ms)
35: [ RUN      ] simd.device
35: CUDA error: an illegal memory access was encountered 
35: Libomptarget error: Call to targetDataEnd failed, abort target.
35: Libomptarget error: Failed to process data after launching the kernel.
35: Libomptarget error: Consult https://openmp.llvm.org/design/Runtimes.html for debugging options.
35: Kokkos_OpenMPTarget_ParallelFor_Range.hpp:54:1: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
35/35 Test #35: Kokkos_UnitTest_SIMD ........................Child aborted***Exception: 114.34 sec

97% tests passed, 1 tests failed out of 35

@@ -33,9 +33,12 @@ struct ParallelReduceCopy {
static void memcpy_result(PointerType dest, PointerType src, size_t size,
bool ptr_on_device) {
if (ptr_on_device) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to mention, everywhere else you have

if(0<size)
  if(ptr_on_device)

While here you have flipped the order of the if conditions. Should not make a difference but just wanted to mention.

@rgayatri23
Copy link
Contributor

The test passed on a A100 machine.

Retest this please.

@crtrott
Copy link
Member

crtrott commented Aug 4, 2023

OpenMPTarget passed on retest. I am assuming that this is an intermittent failure NOT caused by this PR.

@crtrott crtrott merged commit f557d3d into kokkos:develop Aug 4, 2023
27 of 28 checks passed
@masterleinad masterleinad mentioned this pull request Sep 14, 2023
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

7 participants