bartc pisze:
> On 30/11/2026 13:54, fir wrote:
>> im a heavy user of float3
>>
>> and functions liek
>>
>>
>> typedef struct {float x,y,z;} float3 ;
>> typedef struct { float3 pos, right, down, dir;} Position ;
>> typedef struct {float3 a,b,c;} tri ;
>>
>>
>>
>> inline float3 f3(float x,float y,float z) { return (float3){x,y,z}; }
>> inline float dot(float3 a, float3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
>> inline float3 cross(float3 a, float3 b) { return (float3) {a.y*b.z- a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x}; }
>> inline float length(float3 v) { return sqrtf( v.x*v.x + v.y*v.y + v.z*v.z ); }
>>
>> inline float distance(float3 p, float3 q) { float3 a = {q.x-p.x, q.y- p.y, q.z-p.z}; return length(a); }
>>
>> inline float length3(float x, float y, float z) { return sqrtf( x*x + y*y + z*z ); }
>>
>> inline float3 mul(float3 m, float s) { return f3(m.x*s,m.y*s,m.z*s); }
>
> You're passing a struct by value. C will do lots of copying here, which is likely to take longer than the savings of using SIMD.
>
> Use pointers instead.
>
> Even then, you are doing one operation at a time, each one having the function call overhead, even using pointers.
>
> For best efficiency, do lots of them in a loop within the same function.
>
> /Then/ look at possibly using SIMD. From C, lookup gcc SIMD intrinsics.
>
>
you see the words inline? if i write inline functions then i guess
passing by value and by pointer not makes difference...and i would assume compiler is not so stupid to not not inline it...
it generalli inlines quite heavier functions if asked, so he could
inline small