CCS 5.2.1
Complier 7.4.12
将OpenMP矩阵乘向量例程 修改之后 下载 程序如下:
#include <ti/omp/omp.h>
#include <c6x.h>
#include <cache.h>
#include <stdio.h>
//#include "KeyStone_common.h"
//#define MAX_CORE_NUM 8
#define SIZE 100 //定义矩阵大小
// 矩阵初始化,给矩阵赋初值
void Init_Matrix(int Matrix[][SIZE],float temp)
{
int i,j;
for(i =0;i<SIZE;i++)
{
for(j = 0;j <SIZE;j++)
Matrix[i][j] = temp ++;
}
}
//打印矩阵
void Print_Matrix(int Matrix[][SIZE],char* matrixName)
{
int i,j;
for(i =0;i<SIZE;i++)
{
for(j = 0;j <SIZE;j++)
{
printf("%s[%d][%d] %d ",matrixName,i,j,Matrix[i][j] );
}printf("\n");
}
}
/*******************************************************
* main函数入口
******************************************************/
void main()
{
Cache_disable(Cache_Type_L1D);
unsigned long long start; //定义两个变量记录程序开始时间和结束时间
unsigned long long end;
TSCH = 0;
TSCL =0;
start = _itoll(TSCH,TSCL);
int src[SIZE][SIZE], dest[SIZE][SIZE], c[SIZE][SIZE];
int i,j,k;
// for(i =0 ; i<MAX_CORE_NUM;i++)
// {
// CGEM_regs->MAR[(0x10800000+i*0x1000000)/16/1024/1024]=0; // 将全局地址设置为noncacheable
// }
for(i=0;i<SIZE;i++)
for(j=0;j<SIZE;j++)
{
c[i][j]=0;
}
//初始化矩阵
Init_Matrix(src,2);
Init_Matrix(dest,10);
// 打印矩阵初始化的值
// Print_Matrix(src,"src");
// Print_Matrix(dest,"dest");
//将任务分解,定义每个变量的属性
#pragma omp parallel shared(src,dest,c) private(i)
{
#pragma omp for private(j,k)
for (i=0; i < SIZE; i++)
{
for (j=0; j < SIZE; j++)
{
for(k=0;k<SIZE;k++)
{
c[i][j] += (src[i][k] * dest[k][j]);
}
}
}
}
// 将矩阵运算结果打印输出
// Print_Matrix(c,"result");
end = _itoll(TSCH,TSCL);
printf("timeElapsed clocks %d\n",(end-start));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
报如下错误:
[C66xx_0] A0=0x90000200 A1=0x90000200
A2=0x0 A3=0xee
A4=0x2674a284 A5=0x90000200
A6=0x981944de A7=0x0
A8=0x1844018 A9=0x1
A10=0x2 A11=0xa0194a84
A12=0xee81b414 A13=0xc0379c8
A14=0x90000200 A15=0x0
A16=0x90000008 A17=0x8
A18=0x90000180 A19=0x40
A20=0x100 A21=0x34
A22[C66xx_0] =0x818760 A23=0x80bb4c
A24=0x882a6004 A25=0x11406b41
A26=0xb98e0a70 A27=0x25a0001e
A28=0x420840 A29=0xc0366c4
A30=0x2 A31=0xa019205c
B0=0x1 B1=0x1
B2=0x1 B3=0xc02abf0
B4=0x90000200 B5=0xc0379c8
B6=0x0 B7=0x1
B8=0x1000 B9=0x0
B10=0x90000088 B11=0x0
B12=0x1 [C66xx_0] B13=0xc02b76c
B14=0xa0194878 B15=0x828ee8
B16=0x0 B17=0x829018
B18=0xff B19=0x20
B20=0x20 B21=0x20
B22=0xa04005d1 B23=0x82525b9
B24=0x18028c90 B25=0x40422c44
B26=0x84d2400 B27=0x36f64d31
B28=0x2a100c03 B29=0xd15ea2ff
B30=0x0 B31=0x2
NTSR=0x1000f
ITSR=0xf
I[C66xx_0] RP=0xc025ac8
SSR=0x0
AMR=0x0
RILC=0x0
ILC=0x0
Exception at 0x981944dc
EFR=0x2 NRP=0x981944dc
Internal exception: IERR=0x10
Resource conflict exception
ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x981944dc, sp = 0x00828ee8.
To see more[C66xx_0] exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'
xdc.runtime.Error.raise: terminating execution
请问openmp需要在哪里配置,有没有相关文档
在执行的时候会报如下错误
ti.omp.utils.ThreadLocal: line 132: assertion failure: A_invalidKey: Invalid key encountered
xdc.runtime.Error.raise: terminating execution
请问该如何调试。
谢谢。
yaohui wang1:
回复 Andy Yin1:
非常感谢您的帮助 ,我已经成功的运行起来了第一个openMP程序
yangyang cao:
回复 yaohui wang1:
请问您是如何解决这个问题的呢?