Skip to content

Segmentation fault when doing a "for reduction" with openmp #1143

Answered by EmilyBourne
dominikbell asked this question in Q&A
Discussion options

You must be logged in to vote

I think it is the memory problem described in the stack overflow link.
If I translate:

def mult_reduct1(arr : 'float[:,:]', arr1 : 'float[:,:]'):
    """
    Parameters:
        2 arrays of the same size
    """
    nx = arr.shape[1]
    ny = arr.shape[0]

    #$ omp parallel private (i, j)
    #$ omp for reduction(+: arr1)
    for i in range(nx):
        j = i * i

        arr1[0,0] += arr[i,0]**2
        arr1[1,1] += arr[i,1]**2

    #$ omp end parallel


def mult_reduct2(arr : 'float[:,:]', arr1 : 'float[:,:]', arr2 : 'float[:,:]'):
    """
    Parameters:
        3 arrays of the same size
    """
    nx = arr.shape[1]
    ny = arr.shape[0]

    #$ omp parallel private (i, j)
    #$ om…

Replies: 21 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@EmilyBourne
Comment options

Answer selected by EmilyBourne
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #1141 on June 29, 2022 09:04.