Advertisement
Ober3550

How does this union work?

Aug 7th, 2020 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. typedef union __declspec(intrin_type) __declspec(align(64)) __m512 {
  2. float m512_f32[16];
  3. } __m512;
  4.  
  5. __m512 gravity;
  6. gravity.m512_f32[i] ?
  7. gravity->m512_f32[i] ?
  8. gravity::m512_f32[i] ?
  9.  
  10. struct PlanetGroup {
  11. union {
  12. int id[VECWIDTH] = {};
  13. __m256i m_id;
  14. };
  15. union {
  16. float x[VECWIDTH] = {};
  17. __m256 m_x;
  18. };
  19. union {
  20. float y[VECWIDTH] = {};
  21. __m256 m_y;
  22. };
  23. union {
  24. float dx[VECWIDTH] = {};
  25. __m256 m_dx;
  26. };
  27. union {
  28. float dy[VECWIDTH] = {};
  29. __m256 m_dy;
  30. };
  31. union {
  32. float Fx[VECWIDTH] = {};
  33. __m256 m_Fx;
  34. };
  35. union {
  36. float Fy[VECWIDTH] = {};
  37. __m256 m_Fy;
  38. };
  39. union {
  40. float mass[VECWIDTH] = {};
  41. __m256 m_mass;
  42. };
  43. union {
  44. float r[VECWIDTH] = {};
  45. __m256 m_r;
  46. };
  47. };
  48.  
  49. // I want to just be able to access the __m256 shadows instead of having to declare my own.
  50. // The code is ugly cause of all the shadow declarations
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement