Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment 16 for Vec3f for better simd instructions? #27

Open
RicoP opened this issue Dec 1, 2021 · 4 comments
Open

Alignment 16 for Vec3f for better simd instructions? #27

RicoP opened this issue Dec 1, 2021 · 4 comments

Comments

@RicoP
Copy link

RicoP commented Dec 1, 2021

I was wondering could a explicit alignment attribute for Vec3f improve code generation for SIMD instructions?

#ifdef _WIN32
__declspec(align(16))
#else
__attribute__ ((aligned (16)))
#endif
typedef Vec<3, float>          Vec3f;
@RicoP RicoP changed the title Alignment 16 for Vec3ffor better simd instructions? Alignment 16 for Vec3f for better simd instructions? Dec 1, 2021
@polymonster
Copy link
Owner

yeah if you have a use case for it and the codegen is better, seems like something other people might like as well.

I am using vec3f in other code bases which might be packed in structs so possibly something like AlignedVec3 type? or we could enable on a macro? just so it's not going to break existing code.

do you have any example code showing the improvement in codegen for the aligned types?

@RicoP
Copy link
Author

RicoP commented Dec 1, 2021

I yet have to do some digging and struct packing in my engine before can say if this is going to make a real difference.

@RicoP
Copy link
Author

RicoP commented Dec 1, 2021

but it seems like you can't align a typedef :/

@polymonster
Copy link
Owner

would be good to get some test cases where it shows improvement and then its worth digging into what would be a nice way to add this support. Easiest way is just to enable the alignment on a macro so you can choose to use aligned or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants