Quantcast
Channel: C6000™多核 - 最近的话题
Viewing all articles
Browse latest Browse all 5545

为什么C6678的多核比单核的运行时间长

$
0
0

#include <stdio.h>
#include <stdlib.h>
#include <c6x.h>

void test()
{
int a = 0;
for (int i = 0; i<100000; i++)
a++;
printf("a is :%ld\n",a);
}
int main()
{
printf("starting running\n");
unsigned long long t1,t2;
TSCL = 0;
TSCH = 0;
t1 = _itoll(TSCH,TSCL);
for (int i = 0; i<100; i++)
test();
t2 = _itoll(TSCH,TSCL);
printf("time is: %ld\n",(t2-t1));
}

这个时我单核的一个Demo,运行时间时210318543

#include <ti/omp/omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <c6x.h>
void test()
{
int a = 0;
for (int j = 0; j<100000; j++)
a++;
printf("a is :%ld\n",a);
}
void main()
{
printf("starting running\n");
unsigned long long t1,t2;
TSCL = 0;
TSCH = 0;
t1 = _itoll(TSCH,TSCL);
#pragma omp parallel for
for (int i = 0; i<100; i++)
test();
t2 = _itoll(TSCH,TSCL);
printf("time is: %ld\n",(t2-t1));
}

这个时我用OMP指定四核来跑这个Demo,时间是682829192.

按理说多核的时间应该比单核少3倍多,怎么反而多了3倍多呢???


Viewing all articles
Browse latest Browse all 5545

Trending Articles