static void measure_sobel()
{
Int status;
MessageQ_Msg msg;
if (selfId == 0) {
msg = MessageQ_alloc(HEAP_ID, MESSAGE_SIZE_IN_BYTES);
if (msg == NULL) {
System_abort("MessageQ_alloc failed\n");
}
rawtimestamps0 = Timestamp_get32();
/* Kick off the loop */
rawtimestamps[0] = Timestamp_get32();
status = MessageQ_put(nextQueueId, msg);
rawtimestamps2 = Timestamp_get32();
IMG_sobel_3x3_8((uint8_t *)0x90000000,(uint8_t *)0x91000000,1920,1080/8);
rawtimestamps3 = Timestamp_get32();
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
rawtimestamps1 = Timestamp_get32();
System_printf("Whole complete cost %d\n",rawtimestamps1-rawtimestamps0);
System_printf("core0 complete cost %d\n",rawtimestamps3-rawtimestamps2);
}
else if(1<=selfId<=6)
{
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
status = MessageQ_put(nextQueueId, msg);
rawtimestamps4 = Timestamp_get32();
IMG_sobel_3x3_8((uint8_t *)(0x90000000+(1920*1080/8)*selfId),(uint8_t *)(0x91000000+(1920*1080/8)*selfId),1920,1080/8);
rawtimestamps5 = Timestamp_get32();
System_printf("core%d complete cost %d\n",selfId,rawtimestamps5-rawtimestamps4);
}
else
{
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
rawtimestamps2 = Timestamp_get32();
IMG_sobel_3x3_8((uint8_t *)(0x90000000+(1920*1080/8)*selfId),(uint8_t *)(0x91000000+(1920*1080/8)*selfId),1920,1080/8);
rawtimestamps3 = Timestamp_get32();
status = MessageQ_put(nextQueueId, msg);
System_printf("core%d complete cost %d\n",selfId,rawtimestamps3-rawtimestamps2);
}
}
measure_sobel()函数循环执行;八个core是共用一个工程的。
1.Whole complete cost花费时间第一次要94ms;以后只需要2ms
2.所以core完成八分之一,应该处理时间差不多一致的。但是有时候,每个core打印出来的时间相差很大,同时Whole complete cost花费时间也出现明显很大的情况。
我个人觉得,是打印时间方面的问题,是不是不能每个core都获取时间。那个获取时间API具体不清楚怎么做的。
然后如果我使用主从方式的多核通信机制。void convert_func()循环执行
Whole complete cost每次花费时间都为2ms
但是,如果我每个core都添加获取时间,打印时间的话,打印出来的结果又很不合逻辑,相差很大。
void convert_func(){
Int status;
int i;
MessageQ_Msg msg[7];
if (selfId == 0) {
for(i=0;i<7;i++){
msg[i]= MessageQ_alloc(HEAP_ID, MESSAGE_SIZE_IN_BYTES);
if (msg== NULL) {
System_abort("MessageQ_alloc failed\n");
}
}
timeStamp1 = Timestamp_get32();//getStartTime64();
status = MessageQ_put(nextQueueId1, msg[0]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
status = MessageQ_put(nextQueueId2, msg[1]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
status = MessageQ_put(nextQueueId3, msg[2]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
status = MessageQ_put(nextQueueId4, msg[3]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
status = MessageQ_put(nextQueueId5, msg[4]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
status = MessageQ_put(nextQueueId6, msg[5]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
} status = MessageQ_put(nextQueueId7, msg[6]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
System_printf("core 0 MessageQ_put done\n");
System_printf("convert start\n");
timeStamp3 = Timestamp_get32();//getStartTime64();
IMG_sobel_3x3_8((uint8_t *)0x90000000,(uint8_t *)0x91000000,1920,1080/8);
timeStamp4 = Timestamp_get32();
for(i=0;i<7;i++){
status = MessageQ_get(messageQ, &msg[i], MessageQ_FOREVER);
if (status < 0) {
System_abort("MessageQ_get failed\n");
}
}
timeStamp2 =Timestamp_get32();
System_printf("Whole covert time is %d\n",timeStamp2-timeStamp1);
System_printf("core0 covert time is %d\n",timeStamp4-timeStamp3);
}
else{
status = MessageQ_get(messageQ, &msg[selfId-1], MessageQ_FOREVER);
if (status < 0) {
System_abort("MessageQ_get failed\n");
}
timeStamp3 = Timestamp_get32();
IMG_sobel_3x3_8((uint8_t *)(0x90000000+(1920*1080/8)*selfId),(uint8_t *)(0x91000000+(1920*1080/8)*selfId),1920,1080/8);
timeStamp4 = Timestamp_get32();
status = MessageQ_put(nextQueueId, msg[selfId-1]);
if (status < 0) {
System_abort("MessageQ_put failed\n");
}
System_printf("core%d covert time is %d\n",selfId,timeStamp4-timeStamp3);
}
}