Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29114 Discussions

Segmentation Fault (Core Dumped) when Using Intel Sequential MKL DGEMM Inside OpenMP Parallel Loop

AkhilAkkapelli
Beginner
429 Views

I'm trying to perform matrix multiplication using Intel Fortran Compiler (ifort) with OpenMP and MKL's DGEMM routine. The code divides matrices into blocks and uses OpenMP for parallel execution. However, I encounter a "Segmentation fault (core dumped)" error when running the program.

compilation command:  ifort -qopenmp -qmkl=sequential matmul.f90

Here’s a simplified version of my code:

 

integer, parameter :: n = 9 ! Number of rows and columns of matrix
integer, parameter :: nt = 3 ! Sq root of number of threads

real(8), dimension(n,n) :: A, B, C

integer :: nb ! Block size
integer :: bi(nt,2) ! Start and End indices of block matrices
integer :: i, j, k
integer :: starttime, endtime, countrate
call omp_set_num_threads(nt*nt)

print*, "Number of OMP Threads", nt*nt

call random_number(A)
call random_number(B)

if (mod(n,nt) == 0) then
    nb = n/nt
else
    nb = n/nt + 1
end if

!print*, "block size", nb

do i = 1, nt
    bi(i,1) = 1 + nb*(i-1)
    bi(i,2) = min(nb*i,n)
end do

call system_clock(starttime, countrate)
!$OMP PARALLEL DO COLLAPSE(2)
do i  = 1, nt
    do j = 1, nt
        call DGEMM('N', 'N', n, n, n, 1.0d0, A(bi(i,1):bi(i,2), :), n, &
                   B(:, bi(j,1):bi(j,2)), n, 0.0d0, &
                   C(bi(i,1):bi(i,2), bi(j,1):bi(j,2)), n)
    end do
end do
!$OMP END PARALLEL DO

call system_clock(endtime)

 

Labels (2)
0 Kudos
0 Replies
Reply