Added missing files

This commit is contained in:
Balhau 2018-12-01 21:19:38 +00:00
parent 7e09862950
commit de2c87e56e
6 changed files with 200 additions and 0 deletions

111
src/core/blist.hpp Normal file
View file

@ -0,0 +1,111 @@
/*
* 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

View file

17
src/core/cpu/avx2.cpp Normal file
View file

@ -0,0 +1,17 @@
#include "avx2.hpp"
#include <iostream>
#include <string>
void core::cpu::avx2::avx_sum(int *a,int *b){
}
void core::cpu::avx2::printAVX2Num(int *num){
for(int i=0;i<avx2::AVX2_INT_SIZE;i++){
cout << i;
if(i<avx2::AVX2_INT_SIZE-1){
cout << ",";
}
}
}

18
src/core/cpu/avx2.hpp Normal file
View file

@ -0,0 +1,18 @@
#ifndef AVX2_H
#define AVX2_H
using namespace std;
/**
* This will define a set of functions
*/
namespace core {
namespace cpu {
class avx2 {
public:
static int const AVX2_INT_SIZE=16;
static void avx_sum(int* a, int* b);
static void printAVX2Num(int* num);
};
};
};
#endif

27
src/core/cpu/naive.cpp Normal file
View file

@ -0,0 +1,27 @@
#include "naive.hpp"
#include <iostream>
void core::cpu::Naive::sum_128_long(int *a,int *b){
long a1 = ((long)a[0] << 32) | a[1];
long a2 = ((long)a[2] << 32) | a[3];
long b1 = ((long)b[0] << 32) | b[1];
long b2 = ((long)b[2] << 32) | b[3];
a1=a1+b1;
a2=a2+b2;
a[0]=a1>>32;
a[1]=a1;
a[2]=a2>>32;
a[3]=a2;
};
void core::cpu::Naive::print(int *num, int len){
for(int i=0;i<len;i++){
cout << num[i] ;
if(i<len-1){
cout << ",";
}
}
cout << endl;
};

27
src/core/cpu/naive.hpp Normal file
View file

@ -0,0 +1,27 @@
#ifndef CORE_CPU_NAIVE_H
#define CORE_CPU_NAIVE_H
using namespace std;
/**
* This will define a set of functions
*/
namespace core {
namespace cpu {
class Naive {
private:
static const unsigned int MASK_32=0xFFFFFFFF;
public:
//Attributes
static const unsigned char LEN_64 = 2;
static const unsigned char LEN_128 = 4;
static const unsigned char LEN_256 = 8;
static const unsigned char LEN_512 = 8;
//Methods
static void sum_128_long(int* a, int* b);
static void print(int* num,int len);
};
};
};
#endif