Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: NEON matrix multiply - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

NEON matrix multiply Rate Topic: -----

#1 User is offline   PPS 

  • Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 24-November 11

Posted 24 November 2011 - 08:41 AM

I'm new to neon and I'm trying to do some multiplication.
I need to do some multiplication of two arrays and I'm trying to learn some NEON assembly.

I have 2 arrays of int16_t elements. Each array has 4 elements (a[0]-a[3] and b[0]-b[3])
I need to produce resulting array c with 4 int16_t values as:
c[0] = a[0] * b[0]
c[1] = a[0] * b[1] + a[1] * b[1]
c[2] = a[0] * b[2] + a[1] * b[2] + a[2] * b[2]
c[3] = a[0] * b[3] + a[1] * b[3] + a[2] * b[3] + a[3] * b[3]


I'm sure that something like that should be trivial in NEON but I have no idea how to get it working.

My approach is like this:
vmov.32   d0, #0  // (destination array c)
//load arrays a and b into d1 and d2:
vld1.16 	d1, [r0] 
vld1.16 	d2, [r1]

vmla.s16 d0, d1, d2[0] 		// 1st column
// ? TODO... rotate 
vmla.s16 d0, d1, d2[1] 		// 2nd column
vmla.s16 d0, d1, d2[2]
vmla.s16 d0, d1, d2[3]




Basically, at the place of my TODO I want to shift elements of array b so that b becomes:
{b[0], b[1], b[2], b[3]} -> {0, b[0], b[1], b[2]}



Is my approach correct, or I cannot do so in arm-neon?
PS. I tried to use intrinsics with evaluation version of RVDS and it seems that it doesn't work: the generated asm is empty and doesn't have these instructions at all!


Thanks.
0

#2 User is offline   shervin 

  • Contributor
  • PipPip
  • Group: Members
  • Posts: 52
  • Joined: 17-September 10

Posted 10 December 2011 - 03:17 AM

View PostPPS, on 24 November 2011 - 08:41 AM, said:

Basically, at the place of my TODO I want to shift elements of array b so that b becomes:
{b[0], b[1], b[2], b[3]} -> {0, b[0], b[1], b[2]}



Maybe you can use the "vsli" instruction to shift the bits across and insert 0 into it. Or perhaps just "vshr" to shift-right?

-Shervin.
1

#3 User is offline   webshaker 

  • Regular Contributor
  • PipPipPip
  • Group: Members
  • Posts: 220
  • Joined: 07-October 10

Posted 10 December 2011 - 09:19 AM

Do you want to optimize one computation

Or do you have an lot of couple of vector to multiply ?
In the second case, you will be able to prepare the next data during the previous calculation.
When you have eliminated the impossible, whatever remains, however improbable, must be the truth
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic