Is there a nice way to use vectors in arrays without spending too much time on allocations?
I have some parallel for loops and if I set 3 scalar variables to certain values, it seems to perform better than if I set one array with 3 elements (and it works in CUDA kernels). I don’t really know why the two are different at all.
It would make my code neater if I could use arrays. I understand StaticArrays are different from regular arrays for some reason. However, I would need to mutate them and have Vectors of StaticArrays.
Here’s an example of what I do in the for loop:
point1 = points[element[k]]; point2 = points[element[k]]; point3 = points[element[k]]; e1 = point2-point1; e2 = point3-point2; e3 = point1-point3; E1 = norm(e1); E2 = norm(e2); E3 = norm(e3);
Note that each
point is a StaticArray. I also do more complicated stuff and function calls.
I’d love to do:
vertices = points[panels[k]]; for v in 1:panelType vnext = v%numVertices+1; e[v] = vertices[vnext]-vertices[v]; E[v] = norm(e[v]); end
Thanks a lot!