Advertisement
herkusas

Untitled

Dec 12th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. // SSE.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. //#include "stdafx.h"
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <cmath>
  8.  
  9. int main(int argc, char** argv) {
  10.  
  11. float X[4];
  12. float Y[4];
  13. float Z[4];
  14. float res[4];
  15.  
  16. for (short i = 1; i <= 1000; i += 4)
  17. for (short j = i + 1; j <= 1000; j += 4)
  18. {
  19. float x = i;
  20. float y = j;
  21. X[0] = x, X[1] = x + 1, X[2] = x + 2, X[3] = x + 3;
  22. Y[0] = y, Y[1] = y + 1, Y[2] = y + 2, Y[3] = y + 3;
  23.  
  24.  
  25. __asm {
  26. VADDPS xmm0, [X]
  27. movups xmm1, [Y]
  28. mulps xmm0, xmm0
  29. mulps xmm1, xmm1
  30. addps xmm0, xmm1
  31. sqrtps xmm1, xmm0
  32. roundps xmm1, xmm1, 1
  33. movups[Z], xmm1
  34. mulps xmm1, xmm1
  35. subps xmm0, xmm1
  36. movups[res], xmm0
  37. }
  38.  
  39. for (int k = 0; k<4; k++)
  40. if (res[k] == 0.0)
  41. printf("%.0f %.0f %.0f \n", x + k, y + k, Z[k]);
  42. }
  43.  
  44. return(0);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement