Refactor
Changed binary directories Fixed cmake files Fixed naive 128bit sum implementation
This commit is contained in:
parent
11378e5ea6
commit
7e09862950
9 changed files with 27 additions and 168 deletions
|
@ -7,7 +7,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|||
|
||||
add_subdirectory(src)
|
||||
add_executable(cpplab main.cpp)
|
||||
add_executable(sse sse.cpp)
|
||||
|
||||
add_executable(
|
||||
sse
|
||||
src/core/cpu/naive.cpp
|
||||
src/core/cpu/avx2.cpp
|
||||
sse.cpp
|
||||
)
|
||||
|
||||
add_executable(c_time time.cpp)
|
||||
|
||||
install(TARGETS cpplab RUNTIME DESTINATION bin)
|
||||
|
|
8
main.cpp
8
main.cpp
|
@ -1,7 +1,7 @@
|
|||
#include <iostream>
|
||||
#include "src/core/blist.h"
|
||||
#include "src/core/blist.hpp"
|
||||
#include "src/core/bmath/bmath.h"
|
||||
#include "src/core/avx2.h"
|
||||
#include "src/core/cpu/avx2.hpp"
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -17,10 +17,6 @@ int main(int argc, char **argv) {
|
|||
int a[avx2::AVX2_INT_SIZE] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10};
|
||||
int b[avx2::AVX2_INT_SIZE] = {0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11};
|
||||
|
||||
avx2::printAVX2Num(a);
|
||||
avx2::printAVX2Num(b);
|
||||
|
||||
avx2::avx_sum(a,b);
|
||||
|
||||
BMath bm1 = BMath();
|
||||
BMath bm2;
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
|
||||
add_subdirectory(core)
|
|
@ -0,0 +1,2 @@
|
|||
add_subdirectory(bmath)
|
||||
add_subdirectory(cpu)
|
|
@ -1,28 +0,0 @@
|
|||
#include "avx2.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace core::cpu;
|
||||
|
||||
namespace core{
|
||||
namespace cpu{
|
||||
void avx2::naive_sum(int *a,int *b){
|
||||
for(int i=0;i<avx2::AVX2_INT_SIZE;i++){
|
||||
a[i] = a[i]+b[i];
|
||||
}
|
||||
}
|
||||
|
||||
void avx2::avx_sum(int *a,int *b){
|
||||
|
||||
}
|
||||
|
||||
void avx2::printAVX2Num(int *num){
|
||||
for(int i=0;i<avx2::AVX2_INT_SIZE;i++){
|
||||
cout << i;
|
||||
if(i<avx2::AVX2_INT_SIZE-1){
|
||||
cout << ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef AVX2_H
|
||||
#define AVX2_H
|
||||
|
||||
using namespace std;
|
||||
/**
|
||||
* This will define a set of functions
|
||||
*/
|
||||
namespace core {
|
||||
namespace cpu {
|
||||
class avx2 {
|
||||
public:
|
||||
static void inline naive_sum(int* a, int* b);
|
||||
static void inline avx_sum(int* a, int* b);
|
||||
static int const AVX2_INT_SIZE=16;
|
||||
static void printAVX2Num(int* num);
|
||||
};
|
||||
};
|
||||
};
|
||||
#endif
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "blist.h"
|
||||
#include "blist.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
|
111
src/core/blist.h
111
src/core/blist.h
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 Vitor Fernandes <email>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BLIST_H
|
||||
#define BLIST_H
|
||||
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
template <typename T>
|
||||
class blist
|
||||
{
|
||||
public:
|
||||
|
||||
typedef struct node{
|
||||
node(T v,node* p,node* n){
|
||||
value = v;
|
||||
next = n;
|
||||
previous = p;
|
||||
}
|
||||
node(T v){
|
||||
value=v;
|
||||
next=NULL;
|
||||
previous=NULL;
|
||||
}
|
||||
T value;
|
||||
node* next;
|
||||
node* previous;
|
||||
} Node;
|
||||
|
||||
blist(){
|
||||
this->rootNode = NULL;
|
||||
this->currentNode=this->rootNode;
|
||||
size = 0;
|
||||
};
|
||||
blist(T value){
|
||||
this->rootNode=new Node(value,NULL,NULL);
|
||||
this->currentNode=this->rootNode;
|
||||
size = 1;
|
||||
};
|
||||
blist(const blist<T>& other){
|
||||
this->rootNode = other.root();
|
||||
};
|
||||
void add(T value){
|
||||
if(this->rootNode==NULL){
|
||||
this->rootNode=new Node(value,NULL,NULL);
|
||||
this->currentNode=rootNode;
|
||||
}else{
|
||||
Node* newNode = new Node(value,currentNode,NULL);
|
||||
this->currentNode->next = newNode;
|
||||
currentNode=newNode;
|
||||
}
|
||||
size++;
|
||||
};
|
||||
~blist(){
|
||||
std::cout << "Destructing list" << std::endl;
|
||||
Node *aux;
|
||||
while(this->currentNode!=this->rootNode){
|
||||
aux = this->currentNode;
|
||||
this->currentNode = this->currentNode->previous;
|
||||
delete aux;
|
||||
}
|
||||
delete this->rootNode;
|
||||
};
|
||||
blist<T>& operator=(const blist& other){
|
||||
this->rootNode = other.root();
|
||||
};
|
||||
bool operator==(const blist& other){
|
||||
this->rootNode==other.root();
|
||||
};
|
||||
Node * root() const {
|
||||
return this->rootNode;
|
||||
};
|
||||
Node * current() const {
|
||||
return this->currentNode;
|
||||
};
|
||||
|
||||
T* values() {
|
||||
T *aux = new T[size];
|
||||
Node *naux = this->rootNode;
|
||||
for(int i=0;i<size;i++){
|
||||
aux[i]=naux->value;
|
||||
naux=naux->next;
|
||||
}
|
||||
return aux;
|
||||
};
|
||||
int getSize(){
|
||||
return size;
|
||||
};
|
||||
private:
|
||||
Node * rootNode;
|
||||
Node * currentNode;
|
||||
int size;
|
||||
};
|
||||
|
||||
#endif // BLIST_H
|
15
sse.cpp
15
sse.cpp
|
@ -2,7 +2,20 @@
|
|||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include "src/core/cpu/naive.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 };
|
||||
|
||||
Naive::print(v1_128,Naive::LEN_128);
|
||||
Naive::print(v2_128,Naive::LEN_128);
|
||||
|
||||
Naive::sum_128_long(v1_128,v2_128);
|
||||
|
||||
Naive::print(v1_128,Naive::LEN_128);
|
||||
Naive::print(v2_128,Naive::LEN_128);
|
||||
|
||||
}
|
Loading…
Reference in a new issue