- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
demoii16_2.cpp
资源名称:Source.rar [点击查看]
上传用户:husern
上传日期:2018-01-20
资源大小:42486k
文件大小:2k
源码类别:
游戏
开发平台:
Visual C++
- // DEMOII16_2.CPP - Hello world SIMD demo
- // I N C L U D E S ///////////////////////////////////////////////////////////
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h> // include important windows stuff
- #include <windowsx.h>
- #include <stdio.h>
- #include <math.h>
- #include <xmmintrin.h> // <-- this is needed for SIMD support (SSE I)
- // MAIN //////////////////////////////////////////////////////////////////
- void main()
- {
- // print out os/processor support
- if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
- printf("nMMX Available.n");
- else
- printf("nMMX NOT Available.n");
- if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
- printf("nXMMI Available.n");
- else
- {
- printf("nXMMI NOT Available.n");
- return;
- } // end if
- // define 3 SIMD packed values, remember always must be 16byte aligned
- __declspec(align(16)) static float x[4] = {1,2,3,4};
- __declspec(align(16)) static float y[4] = {5,6,7,8};
- __declspec(align(16)) static float z[4] = {0,0,0,0};
- __m128 m0, m1, m2;
- // lets do a little SIMD to add X and Y and store the results in Z
- _asm
- {
- lea esi, x
- movaps xmm0, [esi] // move the value of x into XMM0
- addps xmm0, y // add the value of y to XMM0
- movaps z, xmm0 // store the results from XMM0 into z
- } // end asm
- // print the results
- printf("n x[%f,%f,%f,%f]", x[0], x[1], x[2], x[3]);
- printf("n+y[%f,%f,%f,%f]", y[0], y[1], y[2], y[3]);
- printf("n_______________________________________");
- printf("n=z[%f,%f,%f,%f]nn", z[0], z[1], z[2], z[3]);
- } // end main