diff --git a/CMakeLists.txt b/CMakeLists.txt index d69334d..774eab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/main.cpp b/main.cpp index 5079ab0..13a7397 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include -#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 #include @@ -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; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 232c827..82bfe4a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,2 +1 @@ - add_subdirectory(core) \ No newline at end of file diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e69de29..c3cf137 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(bmath) +add_subdirectory(cpu) \ No newline at end of file diff --git a/src/core/avx2.cpp b/src/core/avx2.cpp deleted file mode 100644 index c1d8247..0000000 --- a/src/core/avx2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "avx2.h" -#include -#include - -using namespace core::cpu; - -namespace core{ - namespace cpu{ - void avx2::naive_sum(int *a,int *b){ - for(int i=0;i #include diff --git a/src/core/blist.h b/src/core/blist.h deleted file mode 100644 index 092ce79..0000000 --- a/src/core/blist.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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/sse.cpp b/sse.cpp index 8339866..7be0245 100644 --- a/sse.cpp +++ b/sse.cpp @@ -2,7 +2,20 @@ #include #include +#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); + } \ No newline at end of file