Skip to content

Commit

Permalink
Identify NVHPC compiler bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Mar 20, 2024
1 parent ff581a1 commit 39cf730
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" )
# Compilation works, but runtime segmentation faults occur (tested with pgi/17.7)
set( FEATURE_FINAL_DEFAULT OFF )
else()
list( APPEND FCKIT_QUARANTAINED_TESTS fckit_test_shared_ptr )
# list( APPEND FCKIT_QUARANTAINED_TESTS fckit_test_shared_ptr )
# deallocation of list of shared_ptr only seems to deallocate first entry
endif()
endif()
Expand Down
40 changes: 39 additions & 1 deletion src/tests/test_shared_ptr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ subroutine test_shared_object_allocatable( final_auto, deallocate_auto )
#else
#define CRAY_WORKAROUND .false.
#endif
#if defined(__NVCOMPILER) && FCKIT_HAVE_FINAL
#define NV_WORKAROUND .true.
#else
#define NV_WORKAROUND .false.
#endif

subroutine test_shared_object_allocatable_list( final_auto, deallocate_auto )

Expand Down Expand Up @@ -556,12 +561,24 @@ subroutine test_shared_object_allocatable_list( final_auto, deallocate_auto )
write(0,'(A)') "Therefore we avoid the deallocate( list ) above, to make test pass."
write(0,'(A)') "This means that with FCKIT_HAVE_FINAL turn on, we cannot manually call deallocate(list)"
else
if (final_auto .and. NV_WORKAROUND ) then
write(0,*) " WARNING: nvidia workaround needed"
write(0,*) " + call list(2)%final()"
call list(2)%final()
endif
deallocate( list )
endif
endif

write(0,'(A)') "~~~~~~~~~~~~~~~ END SCOPE ~~~~~~~~~~~~~~~"
call end_scope()

if (final_auto .and. deallocate_auto .and. NV_WORKAROUND ) then
write(0,*) " WARNING: nvidia workaround needed"
write(0,*) " + call list(2)%final()"
call list(2)%final()
endif

end subroutine

TEST( test_shared_object_allocatable_list_auto_auto )
Expand Down Expand Up @@ -682,11 +699,23 @@ subroutine test_shared_object_pointer_list( final_auto, deallocate_auto )
if( .not. deallocate_auto ) then
write(0,'(A)') "~~~~~~~~~~~~~~ DEALLOCATE ~~~~~~~~~~~~~~~"
deallocate_called = .true.
if (final_auto .and. NV_WORKAROUND ) then
write(0,*) " WARNING: nvidia workaround needed"
write(0,*) " + call list(2)%final()"
call list(2)%final()
endif
deallocate( list )
endif

write(0,'(A)') "~~~~~~~~~~~~~~~ END SCOPE ~~~~~~~~~~~~~~~"
call end_scope()

if (final_auto .and. deallocate_auto .and. NV_WORKAROUND ) then
write(0,*) " WARNING: nvidia workaround needed"
write(0,*) " + call list(2)%final()"
call list(2)%final()
endif

if( associated(list) ) deallocate( list )
end subroutine

Expand Down Expand Up @@ -787,6 +816,15 @@ subroutine test_shared_object_automatic_list( final_auto )

write(0,'(A)') "~~~~~~~~~~~~~~~ END SCOPE ~~~~~~~~~~~~~~~"
call end_scope()

if (final_auto .and. NV_WORKAROUND ) then
write(0,*) " WARNING: nvidia workaround needed"
write(0,*) " + call list(1)%final()"
call list(1)%final()
write(0,*) " + call list(2)%final()"
call list(2)%final()
endif

#endif
end subroutine

Expand Down

0 comments on commit 39cf730

Please sign in to comment.