реклама на сайте
подробности

 
 
> В чем причина различного написания для Cortex M4 и М0?
Михась
сообщение Nov 18 2015, 03:04
Сообщение #1


Частый гость
**

Группа: Участник
Сообщений: 161
Регистрация: 29-09-10
Пользователь №: 59 816



Библиотека DSP STM32F4xx_DSP_StdPeriph_Lib_V1.4.0
Файл arm_add_q31.c


Прошу разъяснить, какие отличия архитектуры Cortex-M3, M4 заставляют группировать по 4 операции в цикле, в отличии от одной операции в цикле для M0. Это для правильной работы конвеера?

Код
/**    
* @brief Q31 vector addition.    
* @param[in]       *pSrcA points to the first input vector    
* @param[in]       *pSrcB points to the second input vector    
* @param[out]      *pDst points to the output vector    
* @param[in]       blockSize number of samples in each vector    
* @return none.    
*    
* <b>Scaling and Overflow Behavior:</b>    
* \par    
* The function uses saturating arithmetic.    
* Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] will be saturated.    
*/

void arm_add_q31(
  q31_t * pSrcA,
  q31_t * pSrcB,
  q31_t * pDst,
  uint32_t blockSize)
{
  uint32_t blkCnt;                               /* loop counter */

#ifndef ARM_MATH_CM0_FAMILY

/* Run the below code for Cortex-M4 and Cortex-M3 */
  q31_t inA1, inA2, inA3, inA4;
  q31_t inB1, inB2, inB3, inB4;

  /*loop Unrolling */
  blkCnt = blockSize >> 2u;

  /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.    
   ** a second loop below computes the remaining 1 to 3 samples. */
  while(blkCnt > 0u)
  {
    /* C = A + B */
    /* Add and then store the results in the destination buffer. */
    inA1 = *pSrcA++;
    inA2 = *pSrcA++;
    inB1 = *pSrcB++;
    inB2 = *pSrcB++;

    inA3 = *pSrcA++;
    inA4 = *pSrcA++;
    inB3 = *pSrcB++;
    inB4 = *pSrcB++;

    *pDst++ = __QADD(inA1, inB1);
    *pDst++ = __QADD(inA2, inB2);
    *pDst++ = __QADD(inA3, inB3);
    *pDst++ = __QADD(inA4, inB4);

    /* Decrement the loop counter */
    blkCnt--;
  }

  /* If the blockSize is not a multiple of 4, compute any remaining output samples here.    
   ** No loop unrolling is used. */
  blkCnt = blockSize % 0x4u;

  while(blkCnt > 0u)
  {
    /* C = A + B */
    /* Add and then store the results in the destination buffer. */
    *pDst++ = __QADD(*pSrcA++, *pSrcB++);

    /* Decrement the loop counter */
    blkCnt--;
  }

#else

  /* Run the below code for Cortex-M0 */



  /* Initialize blkCnt with number of samples */
  blkCnt = blockSize;

  while(blkCnt > 0u)
  {
    /* C = A + B */
    /* Add and then store the results in the destination buffer. */
    *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrcA++ + *pSrcB++);

    /* Decrement the loop counter */
    blkCnt--;
  }

#endif /* #ifndef ARM_MATH_CM0_FAMILY */

}
Go to the top of the page
 
+Quote Post
2 страниц V  < 1 2  
Start new topic
Ответов (15 - 17)
_Pasha
сообщение Nov 19 2015, 15:43
Сообщение #16


;
******

Группа: Участник
Сообщений: 5 646
Регистрация: 1-08-07
Пользователь №: 29 509



Цитата(megajohn @ Nov 18 2015, 14:41) *
P.S. словоблуды до While докопались

да можно не обращать внимания, если бы не тот факт, что это DSPLib
Go to the top of the page
 
+Quote Post
Михась
сообщение Nov 20 2015, 10:04
Сообщение #17


Частый гость
**

Группа: Участник
Сообщений: 161
Регистрация: 29-09-10
Пользователь №: 59 816



Воспользовался объективной наукой - метрологией rolleyes.gif

Код
STM32F4xx_DSP_StdPeriph_Lib_V1.4.0
Кейл MDK, эмулятор 12МГц
arm_add_q31( Ain, Bin, Yout, 10);
Результаты:

Оптимизация        -0+time    -3+time
(M0)            31,083us    18,250us
(M3)            33,833us    15,750us
(M4)            12,083us    9,250us
Go to the top of the page
 
+Quote Post
ViKo
сообщение Nov 20 2015, 10:52
Сообщение #18


Универсальный солдатик
******

Группа: Модераторы
Сообщений: 8 634
Регистрация: 1-11-05
Из: Минск
Пользователь №: 10 362



Цитата(Михась @ Nov 20 2015, 13:04) *
Воспользовался объективной наукой - метрологией rolleyes.gif

Все предсказуемо, кроме разницы M0 и M3 при -0. Если бы M0+, то у него команда за 2 такта выполняется, а у M0 и M3 за 3. Конвейер скрывает эти особенности, сколько может.
https://www.arm.com/products/processors/cortex-m/index.php
Go to the top of the page
 
+Quote Post

2 страниц V  < 1 2
Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 27th July 2025 - 15:18
Рейтинг@Mail.ru


Страница сгенерированна за 0.01407 секунд с 7
ELECTRONIX ©2004-2016