您好: 我使用的是C6678的开发板,仿真器XDS100v,目前只在软件仿真。 任务是:想要完成多核图像处理,使用主核对图像进行分块,从核对每个数据块进行处理,再使用主核对各个处理结果进行整合。 问题是:使用notify()的例程,在从核程序中加入自己编写的子函数,在对数据块完成处理以后,程序卡停,不能激活主核进行结果整合。(尝试加入只有打印信息的子函数,可以完成主从核之间通信,没有问题。) 卡了很久很久了,找不到原因,希望能尽快解答,万分感谢! DEBUG结果如图:(请问会停在这里的原因是什么?)
没有从核2的sent 打印信息,也没有主核0的最后接收打印信息
使用test子函数,可以看到完整的打印信息:
代码如下:
#include <xdc/std.h>/* -----------------------------------XDC.RUNTIME module Headers */#include <xdc/runtime/System.h>/* ----------------------------------- IPC module Headers */#include <ti/ipc/MultiProc.h>#include <ti/ipc/Notify.h>#include <ti/ipc/Ipc.h>/* ----------------------------------- BIOS6 module Headers */#include <ti/sysbios/knl/Semaphore.h>#include <ti/sysbios/knl/Task.h>#include <ti/sysbios/BIOS.h>/* ----------------------------------- To get globals from .cfg Header */#include <xdc/cfg/global.h>///////#include <stdio.h>//#include "ti/omp/omp.h"#include <c6x.h>#include <stdint.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <ti/csl/csl_chip.h>#include <ti/csl/src/intc/csl_intc.h>#include <ti/csl/csl_cpintcAux.h>#include "ipc_interrupt.h"#include "math.h"#include "image.h"///////#define INTERRUPT_LINE 0/* Notify event number that the app uses */#define EVENTID 10/* Number of times to run the loop */#define NUMLOOPS 1UInt32 times = 0;UInt16 recvnumes = 0;#define masterProc 0#define sloverProc1 1#define sloverProc2 2#define sloverNum 2int readimagedata(const double *fp);void R1_inversion(double z[512][169]);void Rn_inversion(double z[512][169]);void R_RXD(double z[512][169],double z1[512]);void logo_matrix();void logo_h();void restore();void test(double z[512][169]);static double h[4096][169];static double g[4096][169];double m=0.000000001;double rr=0;double f[4096],R1[169][169],R2[169],R22[169],Rm[169][169],r1_matrix[169][169],D1[169];double z1[512][169],z2[512][169],z3[512][169],z4[512][169],z5[512][169],z6[512][169],z7[512][169],z8[512][169];double z11[512],z22[512],z33[512],z44[512],z55[512],z66[512],z77[512],z88[512];int m1[512],m2[512],m3[512],m4[512],m5[512],m6[512],m7[512],m8[512];int k[64][64];/* * ======== cbFxn ======== * This function was registered with Notify. It is called when any event is * sent to this processor. */Void cbFxn(UInt16 procId, UInt16 lineId, UInt32 eventId, UArg arg, UInt32 payload){ /* The payload is a sequence number. */ if(procId!=masterProc) // 主核注册函数 { recvnumes++; // 接收从核的数目 if(recvnumes==sloverNum) // 当收到全部从核回复的信息 { recvnumes=0; Semaphore_post(semHandle); } } else{ times = payload; // 执行次数 Semaphore_post(semHandle); }}/* * ======== tsk0_func ======== * Sends an event to the next processor then pends on a semaphore. * The semaphore is posted by the callback function. */Void tsk0_func(UArg arg0, UArg arg1){ Int i = 1; Int status; if (MultiProc_self() == masterProc) { while (i <= NUMLOOPS) { /* 这里可以添加主核需要执行的任务代码*/ readimagedata(image); logo_matrix(); logo_h(); //R1_inversion(z1); //Rn_inversion(z1); //R_RXD(z1,z11); printf("this is multicore,biubiubiu~~~"); /* Send an event to the next processor */ status = Notify_sendEvent(sloverProc1, INTERRUPT_LINE, EVENTID, i, TRUE); status = Notify_sendEvent(sloverProc2, INTERRUPT_LINE, EVENTID, i, TRUE); /* Continue until remote side is up */ if (status < 0) { continue; } System_printf("MasterCore Sent Event to SloverCores in %d
", i); /* Wait to be released by the cbFxn posting the semaphore */ Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 主核等待所有从核完成其工作返回 System_printf("MasterCore Received Event from All SloverCores in %d
",i); /* restore(); FILE *fp1; int j=0; if((fp1=fopen("E:\ccs_workspace\RX_multicore\RX_result.txt","w"))==NULL) { printf("cannot write file!
"); } printf("result ready!"); for(i=0;i<64;i++) { for(j=0;j<64;j++) { fprintf(fp1,"%lf ",g
[j]); if(j==63)fprintf(fp1,"
"); } } fclose(fp1);*/ printf("result complete!"); /* increment for next iteration */ i++; } } else { while (times < NUMLOOPS) { /* wait forever on a semaphore, semaphore is posted in callback */ Semaphore_pend(semHandle, BIOS_WAIT_FOREVER); // 等待主核通知开始执行任务 System_printf("SloverCore%d Received Event from MasterCore in %d
", MultiProc_self(),times); /* 这里可以添加从核执行的任务*/ //uint32_t coreID = CSL_chipReadReg (CSL_CHIP_DNUM); if (1==DNUM) { printf("this is core 1!"); //test(z2); R1_inversion(z2); //Rn_inversion(z2); //R_RXD(z2,z22); } else if (2==DNUM) { printf("this is core 2!"); // test(z3); R1_inversion(z3); //printf("core2 end!"); // Rn_inversion(z3); //R_RXD(z3,z33); } /* Send an event to the next processor */ status = Notify_sendEvent(masterProc, INTERRUPT_LINE, EVENTID, times, TRUE); if (status < 0) { System_abort("sendEvent to MasterCore failed
"); } System_printf("SloverCore%d sent Event from MasterCore in %d
", MultiProc_self(),times); } } System_printf("Test completed
"); BIOS_exit(0);}/* * ======== main ======== * Synchronizes all processors (in Ipc_start), calls BIOS_start, and registers * for an incoming event */Int main(Int argc, Char* argv[]){ Int status; status = Ipc_start(); printf("Ipc_start ok!"); if (status < 0) { System_abort("Ipc_start failed
"); } if(MultiProc_self()==masterProc) { while(Ipc_attach(sloverProc1)){ Task_sleep(1); }// 完成从核1的连接 while(Ipc_attach(sloverProc2)){ Task_sleep(1); }// 完成从核2的连接 status = Notify_registerEvent(sloverProc1, INTERRUPT_LINE, EVENTID, (Notify_FnNotifyCbck)cbFxn, NULL); if (status < 0) { System_abort("Notify_registerEvent for sloverCore1 failed
"); }// 完成从核1的事件注册 status = Notify_registerEvent(sloverProc2, INTERRUPT_LINE, EVENTID, (Notify_FnNotifyCbck)cbFxn, NULL); if (status < 0) { System_abort("Notify_registerEvent for sloverCore2 failed
"); }// 完成从核2的事件注册 } else{ while(Ipc_attach(masterProc)){ Task_sleep(1); }// 完成主核0的连接 status = Notify_registerEvent(masterProc, INTERRUPT_LINE, EVENTID, (Notify_FnNotifyCbck)cbFxn, NULL); if (status < 0) { System_abort("Notify_registerEvent for masterCore0 failed
"); }// 完成主核0的事件注册 } BIOS_start(); return (0);}/* *//* * @(#) ti.sdo.ipc.examples.multicore.evm667x; 1, 0, 0, 0,1; 5-22-2012 16:36:06; /db/vtree/library/trees/ipc/ipc-h32/src/ xlibrary */int readimagedata(const double *fp){ int i,j; printf("readimagedata ok!
"); for (i=0; i<4096; i++) { for (j=0; j<169; j++) { h[j]=*fp; fp+=1; //fscanf(fp, "%lf", &h[j]); //printf("%e ",h[j]); } } printf("readimagedata complete!
"); return 0;}void logo_matrix(){ printf("logo_matrix ok!"); int i=0,j=0; for(i=0;i<64;) { for(j=0;j<64;) { k[j]=1; j=j+2; } i=i+4; } for(i=1;i<64;) { for(j=0;j<64;) { k[j]=2; j=j+2; } i=i+4; } for(i=2;i<64;) { for(j=0;j<64;) { k[j]=3; j=j+2; } i=i+4; } for(i=3;i<64;) { for(j=0;j<64;) { k[j]=4; j=j+2; } i=i+4; } for(i=0;i<64;) { for(j=1;j<64;) { k[j]=5; j=j+2; } i=i+4; } for(i=1;i<64;) { for(j=1;j<64;) { k[j]=6; j=j+2; } i=i+4; } for(i=2;i<64;) { for(j=1;j<64;) { k[j]=7; j=j+2; } i=i+4; } for(i=3;i<64;) { for(j=1;j<64;) { k[j]=8; j=j+2; } i=i+4; } printf("logo_matrix complete!"); return;}void logo_h(){ printf("logo_h ok!"); int i=0,j=0,count=0,a=0,b=0,c=0,d=0,e=0,f=0,g=0,x=0; for(i=0;i<512;i++) { m1=0; m2=0; m3=0; m4=0; m5=0; m6=0; m7=0; m8=0; } for(i=0;i<64;i++) { for(j=0;j<64;j++) { if(k[j]==1) { m1[a]=count; a++; } else if(k[j]==2) { m2=count; b++; } else if(k[j]==3) { m3[c]=count; c++; } else if(k[j]==4) { m4[d]=count; d++; } else if(k[j]==5) { m5[e]=count; e++; } else if(k[j]==6) { m6[f]=count; f++; } else if(k[j]==7) { m7[g]=count; g++; } else if(k[j]==8) { m8[x]=count; x++; } count++; } //count++; } int n=0; for(n=0;n<169;n++) { for(i=0;i<512;i++) { z1[n]=h[m1][n]; z2[n]=h[m2][n]; z3[n]=h[m3][n]; z4[n]=h[m4][n]; z5[n]=h[m5][n]; z6[n]=h[m6][n]; z7[n]=h[m7][n]; z8[n]=h[m8][n]; } } printf("logo-h complete!"); return;}void test(double z[512][169]){ printf("test ok!
"); printf("test complete!
");}
void R1_inversion(double z[512][169]){ printf("R1_inversion ok!
"); int i=0,j=0; rr=0; //float r1_matrix[169][169]; for(i=0;i<169;i++) { for(j=0;j<169;j++) { R1[j]=0; r1_matrix[j]=0; } } for(i=0;i<169;i++) { rr=z[0]*z[0]+rr; } rr=rr/m+1; printf("rr=%e
",rr); for(i=0;i<169;i++) { for(j=0;j<169;j++) { r1_matrix[j]=z[0]*z[0][j]/m/m/rr; if(i==j) R1[j]=1/m-r1_matrix[j]; else R1[j]=-r1_matrix[j]; } } printf("R1_inversion complete!
");}
一周热门 更多>