- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am experiencing a memory leak in my Fortran project. When using PARDISO, which allocates 100,000 units of memory, it appears to be interfering with a portion of the memory already used by Group1, which has allocated 50,000 units. This memory overlap was detected using Intel Inspector. The memory interference by PARDISO with the memory allocated for Group1 did not occur simultaneously. Group1 continues to hold onto its allocated memory, which suggests that PARDISO is encroaching upon memory that should not be accessed or modified while Group1 is still using it.
I would like to understand why PARDISO is causing this memory interference and how to address it. Any guidance on this issue or related documentation would be greatly appreciated.
Thank you for your attention and assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vivid,
Please use "-fsanitize=address" to check for memory leaks instead of Inspector. Intel Inspector will be deprecated in 2025 and will not be supported thereafter.
I have checked the reproducer for memory leak and there is none.
Please use the following to check for memory leak
ifx -O0 -g -traceback -fsanitize=address -qmkl <name of your file>.f90
./a.out
F.Y.I
I am also attaching a test program (ifx_memory_leak.f90) that contains memory leaks and can be identified with -fsanitize=address
program my_program
implicit none
integer, pointer :: x(:) => NULL()
allocate(x(24))
allocate(x(42))
end program my_program
Once you compile and run this as
$ ifx -O0 -g -traceback -fsanitize=address ifx_memory_leak.f90
$ ./a.out
shows the following outputs:
=================================================================
==20275==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 136 byte(s) in 1 object(s) allocated from:
#0 0x4d7ce3 in malloc (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x4d7ce3) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#1 0x56b344 in _mm_malloc (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x56b344) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#2 0x517877 in MAIN__ /panfs/users/mahanraj/isvc-jira/ifx_memory_leak.f90:4:5
#3 0x430a7c in main (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x430a7c) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#4 0x149e01fbb24c in __libc_start_main (/lib64/libc.so.6+0x3524c) (BuildId: cfb059a57e69ac95d5dadab831626b3bd48a4309)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vivid
Could you please share a reproducer for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I experienced the same memory leak with the sample example provided by Intel Pardiso.
Therefore, I believe this memory leak issue is an inherent error in Pardiso. If it’s related to the version I’m using, I am open to upgrading.
Here’s the sample example I used.
!===============================================================================
! Copyright 2004-2021 Intel Corporation.
!
! This software and the related documents are Intel copyrighted materials, and
! your use of them is governed by the express license under which they were
! provided to you (License). Unless the License provides otherwise, you may not
! use, modify, copy, publish, distribute, disclose or transmit this software or
! the related documents without Intel's prior written permission.
!
! This software and the related documents are provided as is, with no express
! or implied warranties, other than those that are expressly stated in the
! License.
!===============================================================================
! Content : Intel(R) oneAPI Math Kernel Library (oneMKL) PARDISO Fortran-90
! example
!
!*******************************************************************************
!----------------------------------------------------------------------
! Example program to show the use of the "PARDISO" routine
! for symmetric linear systems
!---------------------------------------------------------------------
INCLUDE 'mkl_pardiso.f90'
PROGRAM pardiso_sym_f90
USE mkl_pardiso
IMPLICIT NONE
INTEGER, PARAMETER :: dp = KIND(1.0D0)
!.. Internal solver memory pointer
TYPE(MKL_PARDISO_HANDLE), ALLOCATABLE :: pt(:)
!.. All other variables
INTEGER maxfct, mnum, mtype, phase, n, nrhs, error, msglvl, nnz
INTEGER error1
INTEGER, ALLOCATABLE :: iparm( : )
INTEGER, ALLOCATABLE :: ia( : )
INTEGER, ALLOCATABLE :: ja( : )
REAL(KIND=DP), ALLOCATABLE :: a( : )
REAL(KIND=DP), ALLOCATABLE :: b( : )
REAL(KIND=DP), ALLOCATABLE :: x( : )
INTEGER i, idum(1)
REAL(KIND=DP) ddum(1)
!.. Fill all arrays containing matrix data.
n = 8
nnz = 18
nrhs = 1
maxfct = 1
mnum = 1
ALLOCATE(ia(n + 1))
ia = (/ 1, 5, 8, 10, 12, 15, 17, 18, 19 /)
ALLOCATE(ja(nnz))
ja = (/ 1, 3, 6, 7, &
2, 3, 5, &
3, 8, &
4, 7, &
5, 6, 7, &
6, 8, &
7, &
8 /)
ALLOCATE(a(nnz))
a = (/ 7.d0, 1.d0, 2.d0, 7.d0, &
-4.d0, 8.d0, 2.d0, &
1.d0, 5.d0, &
7.d0, 9.d0, &
5.d0, 1.d0, 5.d0, &
-1.d0, 5.d0, &
11.d0, &
5.d0 /)
ALLOCATE(b(n))
ALLOCATE(x(n))
!..
!.. Set up PARDISO control parameter
!..
ALLOCATE(iparm(64))
DO i = 1, 64
iparm(i) = 0
END DO
iparm(1) = 1 ! no solver default
iparm(2) = 2 ! fill-in reordering from METIS
iparm(4) = 0 ! no iterative-direct algorithm
iparm(5) = 0 ! no user fill-in reducing permutation
iparm(6) = 0 ! =0 solution on the first n components of x
iparm(8) = 2 ! numbers of iterative refinement steps
iparm(10) = 13 ! perturb the pivot elements with 1E-13
iparm(11) = 1 ! use nonsymmetric permutation and scaling MPS
iparm(13) = 0 ! maximum weighted matching algorithm is switched-off (default for symmetric). Try iparm(13) = 1 in case of inappropriate accuracy
iparm(14) = 0 ! Output: number of perturbed pivots
iparm(18) = -1 ! Output: number of nonzeros in the factor LU
iparm(19) = -1 ! Output: Mflops for LU factorization
iparm(20) = 0 ! Output: Numbers of CG Iterations
error = 0 ! initialize error flag
msglvl = 1 ! print statistical information
mtype = -2 ! symmetric, indefinite
!.. Initialize the internal solver memory pointer. This is only
! necessary for the FIRST call of the PARDISO solver.
ALLOCATE (pt(64))
DO i = 1, 64
pt(i)%DUMMY = 0
END DO
!.. Reordering and Symbolic Factorization, This step also allocates
! all memory that is necessary for the factorization
phase = 11 ! only reordering and symbolic factorization
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, &
idum, nrhs, iparm, msglvl, ddum, ddum, error)
WRITE(*,*) 'Reordering completed ... '
IF (error /= 0) THEN
WRITE(*,*) 'The following ERROR was detected: ', error
GOTO 1000
END IF
WRITE(*,*) 'Number of nonzeros in factors = ',iparm(18)
WRITE(*,*) 'Number of factorization MFLOPS = ',iparm(19)
!.. Factorization.
phase = 22 ! only factorization
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, &
idum, nrhs, iparm, msglvl, ddum, ddum, error)
WRITE(*,*) 'Factorization completed ... '
IF (error /= 0) THEN
WRITE(*,*) 'The following ERROR was detected: ', error
GOTO 1000
ENDIF
!.. Back substitution and iterative refinement
iparm(8) = 2 ! max numbers of iterative refinement steps
phase = 33 ! only solving
DO i = 1, n
b(i) = 1.d0
END DO
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, &
idum, nrhs, iparm, msglvl, b, x, error)
WRITE(*,*) 'Solve completed ... '
IF (error /= 0) THEN
WRITE(*,*) 'The following ERROR was detected: ', error
GOTO 1000
ENDIF
WRITE(*,*) 'The solution of the system is '
DO i = 1, n
WRITE(*,*) ' x(',i,') = ', x(i)
END DO
1000 CONTINUE
!.. Termination and release of memory
phase = -1 ! release internal memory
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, ddum, idum, idum, &
idum, nrhs, iparm, msglvl, ddum, ddum, error1)
IF (ALLOCATED(ia)) DEALLOCATE(ia)
IF (ALLOCATED(ja)) DEALLOCATE(ja)
IF (ALLOCATED(a)) DEALLOCATE(a)
IF (ALLOCATED(b)) DEALLOCATE(b)
IF (ALLOCATED(x)) DEALLOCATE(x)
IF (ALLOCATED(iparm)) DEALLOCATE(iparm)
IF (error1 /= 0) THEN
WRITE(*,*) 'The following ERROR on release stage was detected: ', error1
STOP 1
ENDIF
IF (error /= 0) STOP 1
END PROGRAM pardiso_sym_f90
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vivid,
Thanks for sharing the sample program.
Are you using the latest oneAPI 2024.2?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am currently using Intel Fortran Compiler 2021. If upgrading can resolve memory leaks, I plan to request the purchase of a higher version from my institution. Please help me find solid justification for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vivid, how did you find there is a memory leaking with this sample code? oneMKL use some internal buffers for better performance. Please check this article if you want to disable this: Avoiding Memory Leaks in oneMKL (intel.com)
thanks,
Chao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Chao! I found a memory leak using Intel Inspector. I will refer to the link you provided to resolve it. Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vivid,
Please let me know if the solution provided by Chao worked for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mahan,
Unfortunately, I tried applying the advice, but it did not help solve the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vivid,
Please use "-fsanitize=address" to check for memory leaks instead of Inspector. Intel Inspector will be deprecated in 2025 and will not be supported thereafter.
I have checked the reproducer for memory leak and there is none.
Please use the following to check for memory leak
ifx -O0 -g -traceback -fsanitize=address -qmkl <name of your file>.f90
./a.out
F.Y.I
I am also attaching a test program (ifx_memory_leak.f90) that contains memory leaks and can be identified with -fsanitize=address
program my_program
implicit none
integer, pointer :: x(:) => NULL()
allocate(x(24))
allocate(x(42))
end program my_program
Once you compile and run this as
$ ifx -O0 -g -traceback -fsanitize=address ifx_memory_leak.f90
$ ./a.out
shows the following outputs:
=================================================================
==20275==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 136 byte(s) in 1 object(s) allocated from:
#0 0x4d7ce3 in malloc (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x4d7ce3) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#1 0x56b344 in _mm_malloc (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x56b344) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#2 0x517877 in MAIN__ /panfs/users/mahanraj/isvc-jira/ifx_memory_leak.f90:4:5
#3 0x430a7c in main (/global/panfs05/users/mahanraj/isvc-jira/a.out+0x430a7c) (BuildId: 0a1442026e2fdf6b9dfea9fbd635d46235b65c3a)
#4 0x149e01fbb24c in __libc_start_main (/lib64/libc.so.6+0x3524c) (BuildId: cfb059a57e69ac95d5dadab831626b3bd48a4309)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page