我的sse2代码错误 [英] Error in my sse2 code

查看:86
本文介绍了我的sse2代码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将x [2] [4]转换为__m128i,反之亦然?
看到main.cpp文件上的错误

How do I convert x[2][4] to __m128i and vise versa?
see error on main.cpp file

//.h file
#ifndef _SSEEXAMPLE1_H
#define _SSEEXAMPLE1_H
#include <emmintrin.h>
class sseexample1
{
public:
    void charles(__m128i *x, __m128i *y);
};
#endif
//,cpp file
#include "stdafx.h"
#include <stdio.h>
#include <emmintrin.h>
#include "sseexample1.h"
void sseexample1::charles(__m128i* x,__m128i* y)
{
for (int j = 0;j<4;j++)
{
*&y[j] = _mm_add_epi16(*&x[j],*&x[j+1]);
}
}
//main.cpp file
#include "stdafx.h"
#include <stdio.h>
#include <emmintrin.h>
#include "sseexample1.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    int x[2][4]={1,1,1,1,2,2,2,2};
    int y[2][4];
    sseexample1 z;
    z.charles(x,y);//error C2664: 'sseexample1::charles' : cannot convert parameter 1 from 'int [2][4]' to '__m128i *'
    for (int j = 0; j < 4; j++)
        cout << y[j] << " ";
          cout << endl;
    return 0;
}

推荐答案

这种方式:

This way:

z.charles((__m128i *)x, (__m128i *)y);


这篇关于我的sse2代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆