Replies: 4 comments 1 reply
-
|
Hi @enadream, Sorry for the delay,
In general creating an intermediate object is not a drawback but beneficial for some circumstances:
can indeed be (without extra glm_vec3_copy()): bu if you call as you can see
vec3 can be optimized with simd in the future if there will be enough room for efficiency Struct APIcglm also provides structure api ( see documentation ). Struct api returns intermediate value directly and compilers may produce faster code by return value optimization and reduce extra copy/move operations. Both Array and Struct Api ( including CALL / GLMM APIs too ) can be used together. |
Beta Was this translation helpful? Give feedback.
-
|
@recp I hadn't thought about it this way. Thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
-
|
@recp, thanks for the answer. For safety, I totally understand. However, for optimization, I do not quite understand.
As input parameters, a and b are only worse than dest, I treat c as an output/write buffer, if that is right. Please make more clarifictions. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @manofcosine, Sorry for the delay, was too busy, First of all it is not always about performance but safety too. For performance part;
we doesn't do any write on input params like For performance about this case it has to be measured of course to say something more precise, but since inputs are readonly and only 3 floats; compiler may generate quite good optimized code to pre-fetch all vector into register[s], also access pattern is cache-friendly. We can copy on stack if we prove it is faster then directly access of course... Just wanted to avoid extra copy/move operations ... We copy some input params like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I decided to use cglm instead of glm because I thought glm doesn't make operations in place, I mean it creates an intermediate object to make operations and then copy the result into the target object. I thought if I use cglm that problem wouldn't be in case, however when I read your vec3.h file I saw that you used a lot of intermediate vec3 inorder to do operations and then copy that vector to the dest parameter. Why did you do that ? Why instead of copying results directly into dest vector you created a vec t and then copied it into dest using glm_vec3_copy ? What's the point of that ?
Beta Was this translation helpful? Give feedback.
All reactions