0

I have the problem that I want to do parallelization with Android Renderscript. For this I have to allocate my input data to renderscript and allocate them back. I want to do big matrix multiplications with the size of 8x8 or 64x64 matrices. There are two problems: 1) I cannot allocate two dimensional arrays. 2) forEach executes the loop as often as the size of the allocation. E.g. The input vector has 10 elements the loop will be executed 10 times. To find a solution I did coding. So my matrix is generated randomly in a byte array. This byte array will be coded row or column to an integer array. So I put a 2d array in a one dimensional array with the size of the length. On the other side (Renderscript) I have to decode them, calculating the result and put the back with the allocation. I want to avoid the coding and to speed up the application. Someone know a better solution for my problem?

array[a][b] --> vector[a] or vector[b] but not vector[a*b] Exist there a possible solution?

Irgendw Pointer
  • 1,770
  • 3
  • 30
  • 67

2 Answers2

0

I'm not sure that I fully understand your problem.

Let me try to make a general suggestion based on what I understand.

You can create a wrapper class that transform input index to the internal index via getters and setters, this wrapper can also implement java.lang.Iterable.

Vitaly
  • 2,760
  • 2
  • 19
  • 26
0

To help with the second part of your problem, bind the matrix Allocations to the Renderscript separately and pass rsForEach another Allocation that is sized to the number of operations you want to perform. You can use values set in this Allocation and/or the x argument of the root() function to help you find where to operate on the matrix data.

My answer for operating per row/column of an image gives more details.

Community
  • 1
  • 1
Massycat
  • 551
  • 3
  • 11