PowerQuad-corrupts-memory #2

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

PowerQuad-corrupts-memory #2

2,669件の閲覧回数
Peter19
Contributor II

FRDM-MCXN947 

I am trying to utilize PowerQuad to copy 16-bit buffer to 32-bit buffer and scale in process.

It works fine except every 8th output value is wrong...

Rows = 16, Cols = 8

void arm_mat_q15_to_q31_scaled(
    const arm_matrix_instance_q15* pSrc,
    int32_t shift,
    arm_matrix_instance_q31* pDst)
{
  pq_config_t config;

  PQ_GetDefaultConfig(&config);
  config.inputAFormat   = kPQ_16Bit;
  config.outputFormat   = kPQ_32Bit;
  config.outputPrescale = (int8_t)shift;
  PQ_SetConfig(POWERQUAD, &config);

  float factor = 1.0f; // (float)(1L << shift);
  PQ_MatrixScale(POWERQUAD, 
    POWERQUAD_MAKE_MATRIX_LEN(pSrc->numRows, pSrc->numCols, pDst->numCols),
    factor,
    (void *)pSrc->pData, 
    (void *)pDst->pData);
  
  PQ_WaitDone(POWERQUAD);
}
InputOutputRef

0
3212
6393
9512
12540
15447
18205
20788
23170
25330

0
822272
1636608
2435072
3210240
3954432
4660480
5321728
32767
6484480
0
822272
1636608
2435072
3210240
3954432
4660480
5321728
5931520
6484480

ラベル(3)
0 件の賞賛
返信
7 返答(返信)

2,009件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Peter19 

 

I escalated this issue to our SE team and got a method as follows. Please refer to it. Sorry for the inconvenience caused to you.
 

please refer to SDK example: 

static void arm_mat_scale_q31Test(void)
{
uint32_t srcRows, srcColumns; /* Temporary variables */
arm_matrix_instance_q31 scaleMatrix;
arm_matrix_instance_q31 scaleMatrixR;

float floatInput;
float floatScaler = 0.5f;
q31_t scaler = FLOAT_2_Q31(floatScaler);
q31_t scale[MATRIX_LEN];
q31_t scaleResult[MATRIX_LEN] = {0};
q31_t scaleRel[MATRIX_LEN] = {0};

for (uint32_t i = 0; i < MATRIX_LEN; i++)
{
floatInput = (float)i / (float)MATRIX_LEN;
scale[i] = FLOAT_2_Q31(floatInput);
scaleRel[i] = FLOAT_2_Q31(floatInput * floatScaler);
}

/* Initialise Matrix Instance scaleMatrix with numRows, numCols and data array(scale) */
srcRows = MATRIX_ROW;
srcColumns = MATRIX_COL;
arm_mat_init_q31(&scaleMatrix, srcRows, srcColumns, scale);

uint32_t oldTime = TEST_GetTime();
for (uint32_t i = 0; i < MATRIX_TEST_LOOP; i++)
{
arm_mat_init_q31(&scaleMatrixR, srcRows, srcColumns, scaleResult);
arm_mat_scale_q31(&scaleMatrix, scaler, 0, &scaleMatrixR);
}

PRINTF("%s: %d ms\r\n", __func__, TEST_GetTime() - oldTime);

for (uint32_t i = 0; i < ARRAY_SIZE(scale); i++)
{
EXAMPLE_ASSERT_TRUE(scaleRel[i] == scaleMatrixR.pData[i]);
}
}

 

 

BR

Alice

 

 

0 件の賞賛
返信

2,610件の閲覧回数
Peter19
Contributor II

Hi

Please find attached file.

I import frdmmcxn947_powerquad_math example and replace powerquad_cmsis.c with attached file with content inspired from original example.

Place a debug breakpoint after call and check output.

FRDM-MCXN947 

@Alice_Yang 

0 件の賞賛
返信

2,594件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Peter19 

Thanks for your sharing.

I have checked the function of your code. How about replacing the function arm_mat_q15_to_q31_scaled() with the PowerQuad SDK driver PQ_MatrixScale()?

/*!

* @brief Processing function for the matrix scale.

*

* @param base POWERQUAD peripheral base address

* @param length rows and cols for matrix. LENGTH register configuration:

* LENGTH[23:16] = M2 cols

* LENGTH[15:8] = M1 cols

* LENGTH[7:0] = M1 rows

* This could be constructed using macro @ref POWERQUAD_MAKE_MATRIX_LEN.

* @param misc scaling parameters

* @param pData input matrix

* @param pResult array for the output data.

*/

void PQ_MatrixScale(POWERQUAD_Type *base, uint32_t length, float misc, const void *pData, void *pResult);

 

 

 

Best Regards,

Alice

0 件の賞賛
返信

2,565件の閲覧回数
Peter19
Contributor II

Hi

That is the function I am using and am having problem with. Please refer previous messages in this thread.

BR

/Peter

0 件の賞賛
返信

2,486件の閲覧回数
Peter19
Contributor II

Hi

@Alice_Yang, did you have a chance to look into this?

Regards

/Peter

0 件の賞賛
返信

2,162件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Peter19 

Sorry I just come back from Chinese New Year holiday. I will continue working on this case, and send to you with update.

Many thanks for your understanding.

 

BR

Alice

0 件の賞賛
返信

2,617件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Peter19 

Could you please send a simple project that can reproduce your issue. thanks.

 

BR

Alice

0 件の賞賛
返信