[an error occurred while processing this directive]
|
Вот. Первая - 1047 тактов (на 150 мгц, 6711). Вторая - 2822 такта. точность - 64 бита IEEE double. Никаких ручных оптимизаций, как C скомпилячил.
Программа выполнялась из SDRAM, выполнение функций в первый раз не учитывалось (когда происходила их перегрузка в кеш). Результаты получены на реальной железке через эмулятор. Текст немного подкорректирован в части использования деления и корня на TI'шную либу.
результаты:
первая: 1.938166128296694
вторая: 0.226160194107219
#define CHIP_6711#include
#include
#include#define TI_ENCHANCED_MATH_H 1
#include "fastrts67x.h"
#include "recip.h"#define TYPE double
#define MAX_ERR 0.000001TYPE Math_eq3(TYPE a, TYPE b, TYPE c, TYPE d, TYPE t1)
{
// int i;
TYPE t0, t, y0, y1, de;t0=0.0;
y0=a*t0*t0*t0 + b*t0*t0 + c*t0 + d;
do{
y1=a*t1*t1*t1 + b*t1*t1 + c*t1 + d;t=t1-(y1*(t0-t1))*recipdp(y0-y1);
de=_fabs(t1-t);t0=t1;
t1=t;y0=y1;
}while(de>=MAX_ERR);return t;
}
TYPE EQtype1(TYPE t0, TYPE t1, TYPE p, TYPE j, TYPE K1, TYPE K2)
{
TYPE y0, y1, t, de, g;g=recipdp(rsqrtdp(K1*j+t0*t0)); g=g*g*g;
y0=p*t0*t0*t0 + p*g + 2*K1*t0 - K2;do{
g=recipdp(rsqrtdp(K1*j+t1*t1)); g=g*g*g;
y1=p*t1*t1*t1 + p*g + 2*K1*t1 - K2;t=t1-(y1*(t1-t0))*recipdp(y1-y0);
de=_fabs(t1-t);t0=t1;
t1=t;y0=y1;
}while(de>=MAX_ERR);return t;
}int main(void)
{
int i;
static volatile double res1, res2;CSR=0x100; /* disable all interrupts */
IER=1; /* disable all interrupts except NMI */
ICR=0xffff; /* clear all pending interrupts */
CSL_init();
CACHE_reset();
CACHE_setL2Mode(CACHE_48KCACHE);
CACHE_invalidate(CACHE_L1PALL,(void*)0,0);
CACHE_invalidate(CACHE_L1DALL,(void*)0,0);
CACHE_enableCaching(CACHE_CE00);Math_eq3(1.0/6.0, 0.5, 50, -100, 3);
for (i=0; i<256; i++) {
res1=Math_eq3(1.0/6.0, 0.5, 50, -100, 3);
}EQtype1(0, 0.7777777, 9, 1.0/9.0, 20, 40);
for (i=0; i<256; i++) {
res2=EQtype1(0, 0.7777777, 9, 1.0/9.0, 20, 40);
}
return res1+res2; // to avoid optimizer to kill res1 & res2
}
E-mail: info@telesys.ru