From de2c87e56e5fe2488b9a8b8627c80662a06ff1c6 Mon Sep 17 00:00:00 2001 From: Balhau Date: Sat, 1 Dec 2018 21:19:38 +0000 Subject: [PATCH] Added missing files --- src/core/blist.hpp | 111 ++++++++++++++++++++++++++++++++++++ src/core/cpu/CMakeLists.txt | 0 src/core/cpu/avx2.cpp | 17 ++++++ src/core/cpu/avx2.hpp | 18 ++++++ src/core/cpu/naive.cpp | 27 +++++++++ src/core/cpu/naive.hpp | 27 +++++++++ 6 files changed, 200 insertions(+) create mode 100644 src/core/blist.hpp create mode 100644 src/core/cpu/CMakeLists.txt create mode 100644 src/core/cpu/avx2.cpp create mode 100644 src/core/cpu/avx2.hpp create mode 100644 src/core/cpu/naive.cpp create mode 100644 src/core/cpu/naive.hpp diff --git a/src/core/blist.hpp b/src/core/blist.hpp new file mode 100644 index 0000000..092ce79 --- /dev/null +++ b/src/core/blist.hpp @@ -0,0 +1,111 @@ +/* + * Copyright 2017 Vitor Fernandes + * + * 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 +#include +#include + +template +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& 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& 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;ivalue; + naux=naux->next; + } + return aux; + }; + int getSize(){ + return size; + }; +private: + Node * rootNode; + Node * currentNode; + int size; +}; + +#endif // BLIST_H diff --git a/src/core/cpu/CMakeLists.txt b/src/core/cpu/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/core/cpu/avx2.cpp b/src/core/cpu/avx2.cpp new file mode 100644 index 0000000..238e4be --- /dev/null +++ b/src/core/cpu/avx2.cpp @@ -0,0 +1,17 @@ +#include "avx2.hpp" +#include +#include + + +void core::cpu::avx2::avx_sum(int *a,int *b){ + +} + +void core::cpu::avx2::printAVX2Num(int *num){ + for(int i=0;i + +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