小编Aso*_*han的帖子

(Vec4 x Mat4x4)产品使用SIMD和改进

我正在编写一个复杂的模拟程序,它表明最常用的例程就是将四向量(float4)与4x4矩阵相乘.我需要在几台计算机上运行这个程序,这些计算机或多或少都是旧的.这就是我尝试在以下代码中检查此类操作的SIMD功能的原因:

//#include <xmmintrin.h> // SSE
//#include <pmmintrin.h> // SSE3
//#include <nmmintrin.h> // SSE4.2
  #include <immintrin.h> // AVX

#include <iostream>
#include <ctime>
#include <string>

using namespace std;

// 4-vector.
typedef struct
{
    float x;
    float y;
    float z;
    float w;
}float4;

// typedef to simplify the pointer of function notation.
typedef void(*Function)(float4&,const float4*,const float4&);

float dot( const float4& in_A, const float4& in_x )
{
    return in_A.x*in_x.x + in_A.y*in_x.y + in_A.z*in_x.z + in_A.w*in_x.w; // 7 FLOPS
}

void A_times_x( float4& out_y, const …
Run Code Online (Sandbox Code Playgroud)

c++ simd matrix avx sse3

8
推荐指数
1
解决办法
966
查看次数

标签 统计

avx ×1

c++ ×1

matrix ×1

simd ×1

sse3 ×1