OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

Optimization question

Polar01
Beginner
606 Views
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
606 Views
Good questions. I'm also interestered in this!
0 Kudos
Evgeny_F_Intel
Employee
606 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.

0 Kudos
Reply