Added sse files to implement sse assembly instructions in inline code
This commit is contained in:
parent
de2c87e56e
commit
2db72850bc
4 changed files with 36 additions and 2 deletions
|
@ -10,6 +10,7 @@ add_executable(cpplab main.cpp)
|
|||
|
||||
add_executable(
|
||||
sse
|
||||
src/core/cpu/sse.cpp
|
||||
src/core/cpu/naive.cpp
|
||||
src/core/cpu/avx2.cpp
|
||||
sse.cpp
|
||||
|
|
13
src/core/cpu/sse.cpp
Normal file
13
src/core/cpu/sse.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "sse.hpp"
|
||||
#include <iostream>
|
||||
|
||||
//X86 Assembly to add two 128 bit numbers
|
||||
void core::cpu::SSE::sum_128(int *a,int *b) {
|
||||
asm(
|
||||
"movdqa %0, %%xmm1\n"
|
||||
"paddw %1, %%xmm1\n"
|
||||
"movdqa %%xmm1, %0"
|
||||
: "=m"(*a)
|
||||
: "m"(*b)
|
||||
);
|
||||
}
|
17
src/core/cpu/sse.hpp
Normal file
17
src/core/cpu/sse.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef CORE_CPU_SSE_H
|
||||
#define CORE_CPU_SSE_H
|
||||
|
||||
using namespace std;
|
||||
/**
|
||||
* This will define a set of functions
|
||||
*/
|
||||
namespace core {
|
||||
namespace cpu {
|
||||
class SSE {
|
||||
public:
|
||||
static void sum_128(int *a,int *b);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
7
sse.cpp
7
sse.cpp
|
@ -3,19 +3,22 @@
|
|||
#include <iomanip>
|
||||
|
||||
#include "src/core/cpu/naive.hpp"
|
||||
#include "src/core/cpu/sse.hpp"
|
||||
|
||||
using namespace core::cpu;
|
||||
|
||||
int main(int argc, char** argcv){
|
||||
int v1_128[Naive::LEN_128] = { 0x100, 0x2,0x3,0x4 };
|
||||
int v2_128[Naive::LEN_128] = { 0x10, 0x2,0x3,0x4 };
|
||||
int v1_128[Naive::LEN_128] = { 0x1, 0x2,0x3,0x4 };
|
||||
int v2_128[Naive::LEN_128] = { 0x1, 0x2,0x3,0x4 };
|
||||
|
||||
Naive::print(v1_128,Naive::LEN_128);
|
||||
Naive::print(v2_128,Naive::LEN_128);
|
||||
|
||||
Naive::sum_128_long(v1_128,v2_128);
|
||||
SSE::sum_128(v1_128,v2_128);
|
||||
|
||||
Naive::print(v1_128,Naive::LEN_128);
|
||||
Naive::print(v2_128,Naive::LEN_128);
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue