This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenMP load failed sometimes.

I changed the OpenMP matrix vector multiplication example to matrix_matrix multiplication

It load sometimes failed ,when it failed ,the console print as follow:

when it load success ,core1,core2 and core3 will break out of schedule,the screenshot like this

I can click on the presume button to continue ,than the project can running complete.

Please help me ,I'm fall in this trouble a lot of times .

Thank you.

Best regards

Yewkui Wang

  • Hello Yewkui Wang,

    NRP could be pointing after the exception occurred. Please check and debug the instructions in a couple of fetch packets above this instruction and the rest of the fetch packet after this instruction.

    The address in B3 is usually the return address of a function call, so you can look back to that address to see where this came from. That could help with tracking down the actual cause.

    An exception like this should never occur in compiler-generated code. Causes can be stack overflow, memory corruption from invalid/incorrect pointers, and such.

    Refer more info here.

    Thank you.

  • Hi Rajasekaran K

        Thank you for your response.

         Can you tell me how can I solve the second question?

         It will break only once during the application running,It may casued by core1 out of schedule or core1 core2 and core 3 all out of schedule.

         here is my source code. did the code has problem?

    #include <ti/omp/omp.h>
    #include <stdio.h>
    #include <time.h>
    #include <c6x.h>
    #include <stdlib.h>
    #define SIZE 30
    #define NTHREADS 8

    unsigned long long start,finish;

    void main()
    {
    TSCL = 0;
    int (*A)[SIZE], (*b)[SIZE], (*c)[SIZE];
    A =malloc(sizeof(int)*SIZE*SIZE);
    b = malloc(sizeof(int)*SIZE*SIZE);
    c = malloc(sizeof(int)*SIZE*SIZE);
    start = 0;
    finish = 0;
    int i, j,k, tid;
    srand(time(NULL));

    omp_set_num_threads(NTHREADS);

    for (i=0; i < SIZE; i++)
    {
    for (j=0; j < SIZE; j++)
    {
    A[i][j] = rand()%10; 
    b[i][j] = rand()%10;
    c[i][j] = 0;
    }
    }

    start =TSCL;

    #pragma omp parallel shared(A,b,c) private(tid,i)
    {
    tid = omp_get_thread_num(); //获取当前线程的id
    #pragma omp for private(j,k)//将for循环展开运算
    for (i=0; i < SIZE; i++)
    {
    for (j=0; j <SIZE; j++)
    {
    for(k = 0;k<SIZE;k++)
    {
    c[i][j] += (A[i][k] * b[k][j]); //做矩阵乘法
    }
    }printf(" thread %d did row %d\t \t clockElapsed \n",tid,i);
    }
    }
    finish =TSCL;
    printf(" finsh %ld start %ld The calculation of "
    "whole matrixMultiple is %ld \n\n",
    finish,start,(finish-start));

    for(i = 0; i<SIZE;i++){

    for(j =0; j<SIZE;j++)
    {
    printf(" c[%d][%d]=%4d ",i,j,c[i][j]);
    }printf("\n");
    }
    free(A);
    free(b);
    free(c);
    }

  • Hi Rajasekaran K

    I have solved the second problem.
    This is indeed caused by my program used OpenMP instruction in a incorrect way。
    I should put the printf function into ”#pragma omp critical“ section
    then the program running complete.

    By the way, Is it possible that the first problem caused by a power on reset?
    It always appear after the first time debug after power on.
    When several minutes past ,debug going well.

    I am appreciate your advise.
    Thank you sososo much.

    Best Regards

    Yewkui Wang