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.

6657 Demo板OpenMP测试错误,向各位请教

Other Parts Discussed in Thread: SYSBIOS

没有建cfg文件里没有建Task时,demo板上测试正常。

在cfg文件里建Task时,demo板上测试异常。报错 ti.omp.utils.ThreadLocal: 132 line   assertion failure。

具体工程见附件。

test6657OMPmatrixError.rar
  • 这是你自己创建的OMP工程么,如果工程中没有OMP,此时cfg中创建task能正常么?

    OMP工程参考MCSDK中提供的基于C6670/C6678的OMP例程,安装之后路径mcsdk_2_01_02_06\demos\image_processing\openmp

  • 在cfg中创建task是正常的。

    #include <ti/omp/omp.h>
    #include <stdio.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/BIOS.h>
    #include <xdc/runtime/Error.h>

    #define SIZE 10

    Void tsk0_func(UArg arg0, UArg arg1)
    {
    float A[SIZE][SIZE], b[SIZE], c[SIZE], total;
    int i, j, tid;

    printf("%s %d\n",__FUNCTION__,__LINE__);
    /* Initializations */
    //
    printf("%s %d\n",__FUNCTION__,__LINE__);

    total = 0.0;
    for (i=0; i < SIZE; i++)
    {
    for (j=0; j < SIZE; j++)
    A[i][j] = (j+1) * 1.0;
    b[i] = 1.0 * (i+1);
    c[i] = 0.0;
    }
    printf("\nStarting values of matrix A and vector b:\n");
    for (i=0; i < SIZE; i++)
    {
    printf(" A[%d]= ",i);
    for (j=0; j < SIZE; j++)
    printf("%.1f ",A[i][j]);
    printf(" b[%d]= %.1f\n",i,b[i]);
    }
    printf("\nResults by thread/row:\n");

    /* Create a team of threads and scope variables */
    // #pragma omp parallel shared(A,b,total) private(tid,i,c)
    {
    // tid = omp_get_thread_num();

    /* Loop work-sharing construct - distribute rows of matrix */
    // #pragma omp for private(j)
    for (i=0; i < SIZE; i++)
    {
    for (j=0; j < SIZE; j++)
    c[i] += (A[i][j] * b[i]);

    /* Update and display of running total must be serialized */
    // #pragma omp critical
    {
    total = total + c[i];
    printf(" thread %d did row %d\t c[%d]=%.2f\t",tid,i,i,c[i]);
    printf("Running total= %.2f\n",total);
    }

    } /* end of parallel i loop */

    } /* end of parallel construct */

    printf("\nMatrix-vector total - sum of all c[] = %.2f\n\n",total);
    BIOS_exit(0);
    }

    void main()
    {
    Task_Handle task;
    Task_Params task_params;
    Error_Block eb;

    float A[SIZE][SIZE], b[SIZE], c[SIZE], total;
    int i, j, tid;

    /* Initializations */
    // omp_set_num_threads(2);

    #if 0
    total = 0.0;
    for (i=0; i < SIZE; i++)
    {
    for (j=0; j < SIZE; j++)
    A[i][j] = (j+1) * 1.0;
    b[i] = 1.0 * (i+1);
    c[i] = 0.0;
    }
    printf("\nStarting values of matrix A and vector b:\n");
    for (i=0; i < SIZE; i++)
    {
    printf(" A[%d]= ",i);
    for (j=0; j < SIZE; j++)
    printf("%.1f ",A[i][j]);
    printf(" b[%d]= %.1f\n",i,b[i]);
    }
    printf("\nResults by thread/row:\n");

    /* Create a team of threads and scope variables */
    #pragma omp parallel shared(A,b,total) private(tid,i,c)
    {
    tid = omp_get_thread_num();

    /* Loop work-sharing construct - distribute rows of matrix */
    #pragma omp for private(j)
    for (i=0; i < SIZE; i++)
    {
    for (j=0; j < SIZE; j++)
    c[i] += (A[i][j] * b[i]);

    /* Update and display of running total must be serialized */
    #pragma omp critical
    {
    total = total + c[i];
    printf(" thread %d did row %d\t c[%d]=%.2f\t",tid,i,i,c[i]);
    printf("Running total= %.2f\n",total);
    }

    } /* end of parallel i loop */

    } /* end of parallel construct */

    printf("\nMatrix-vector total - sum of all c[] = %.2f\n\n",total);
    #endif


    BIOS_start();
    }