Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Polar01
Beginner
52 Views

Optimization question

I have a few question to know "how" I should write my methods. Can you tell me which one is the fast one ?
By example to pass values to a method :
1 - Passing float3 by pointer
void mymethod(float3* a, float3* b, float3* result)....

2 - Passing float3 directly
void mymethod(float3 a, float3 b, float3* result)....
3 - using "const" allowing the compiler to keep "a" and avoir a copy when entering into the method
void mymethod(const float3 a, const float3 b, float3* result)....
And to return values
1 - By pointer
void mymethod(float3* a, float3* b, float3* result)....
float3 a;
mymethod(&a);
2 - By value
float3 mymethod(float3* a, float3* b)....
float3 a = mythod(...);
0 Kudos
2 Replies
jogshy
New Contributor I
52 Views

Good questions. I'm also interestered in this!
Evgeny_F_Intel
Employee
52 Views

In most of the cases the compiler will perform in-lining, hence there is no much differences.

If for some reason the compiler can't perform in-lining the following method is preferred.

float3 mymethod(float3,float3);

In any case, I advise you to use the "Offline compiler" tool and look for thex86 assembly.