Refactor code, uniform names clean warning messages and setup c++ compiler to c11

This commit is contained in:
Vitor Fernandes 2020-07-07 17:40:41 +01:00
parent c1540ffa28
commit 3b3041e405
No known key found for this signature in database
GPG key ID: EBFB4EE09F348A26
11 changed files with 18 additions and 24 deletions

View file

@ -5,6 +5,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#Set c++ c11 version
set (CMAKE_CXX_STANDARD 11)
add_subdirectory(src) add_subdirectory(src)
#add_executable(c_time time.cpp) #add_executable(c_time time.cpp)

View file

@ -2,11 +2,13 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
void Cpu::avx2::avx_sum(int *a, int *b) using namespace std;
void CPU::avx2::avx_sum(int *a, int *b)
{ {
} }
void Cpu::avx2::printAVX2Num(int *num) void CPU::avx2::printAVX2Num(int *num)
{ {
for (int i = 0; i < avx2::AVX2_INT_SIZE; i++) for (int i = 0; i < avx2::AVX2_INT_SIZE; i++)
{ {

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
namespace CPU
using namespace std;
namespace Cpu
{ {
class avx2 class avx2
{ {

View file

@ -4,7 +4,7 @@
#include "../naive.hpp" #include "../naive.hpp"
#include <sys/time.h> #include <sys/time.h>
using namespace Cpu; using namespace CPU;
using namespace std; using namespace std;
long int gettime(){ long int gettime(){

View file

@ -2,7 +2,7 @@
#include "types.hpp" #include "types.hpp"
#include <iostream> #include <iostream>
void Cpu::Naive::sum_128_long(UInt *a,UInt *b){ void CPU::Naive::sum_128_long(UInt *a,UInt *b){
ULong a1 = ((ULong)a[0] << 32) | a[1]; ULong a1 = ((ULong)a[0] << 32) | a[1];
ULong a2 = ((ULong)a[2] << 32) | a[3]; ULong a2 = ((ULong)a[2] << 32) | a[3];
ULong b1 = ((ULong)b[0] << 32) | b[1]; ULong b1 = ((ULong)b[0] << 32) | b[1];

View file

@ -1,12 +1,7 @@
#pragma once #pragma once
#include "types.hpp" #include "types.hpp"
namespace CPU
using namespace std;
/**
* This will define a set of functions
*/
namespace Cpu
{ {
class Naive class Naive
{ {

View file

@ -2,7 +2,7 @@
#include <iostream> #include <iostream>
//X86 Assembly to add two 128 bit numbers in the form of packed integers 32bit //X86 Assembly to add two 128 bit numbers in the form of packed integers 32bit
void Cpu::SSE::paddw(UInt *a,UInt *b) { void CPU::SSE::paddw(UInt *a,UInt *b) {
asm( asm(
"movdqa %0, %%xmm1\n" "movdqa %0, %%xmm1\n"
"paddw %1, %%xmm1\n" "paddw %1, %%xmm1\n"
@ -14,7 +14,7 @@ void Cpu::SSE::paddw(UInt *a,UInt *b) {
//X86 Assembly to add two 128 bit numbers in the form of packed long 64bit //X86 Assembly to add two 128 bit numbers in the form of packed long 64bit
void Cpu::SSE::paddd(ULong *a,ULong *b) { void CPU::SSE::paddd(ULong *a,ULong *b) {
asm( asm(
"movdqa %0, %%xmm1\n" "movdqa %0, %%xmm1\n"
"paddd %1, %%xmm1\n" "paddd %1, %%xmm1\n"

View file

@ -2,10 +2,8 @@
#include "types.hpp" #include "types.hpp"
using namespace std;
namespace CPU
namespace Cpu
{ {
class SSE class SSE
{ {

View file

@ -5,7 +5,7 @@
using namespace std; using namespace std;
namespace Cpu namespace CPU
{ {
class Utils class Utils
{ {
@ -39,11 +39,11 @@ public:
static void long128BitToInt(ULong *packedULong, UInt *packedUInteger) static void long128BitToInt(ULong *packedULong, UInt *packedUInteger)
{ {
//Unpack first long //Unpack first long
packedUInteger[0] = packedULong[0] && MASK_32; packedUInteger[0] = packedULong[0] & MASK_32;
packedUInteger[1] = packedULong[0] >> SHIFT_32; packedUInteger[1] = packedULong[0] >> SHIFT_32;
//Unpack second long //Unpack second long
packedUInteger[2] = packedULong[1] && MASK_32; packedUInteger[2] = packedULong[1] & MASK_32;
packedUInteger[3] = packedULong[1] >> SHIFT_32; packedUInteger[3] = packedULong[1] >> SHIFT_32;
}; };
}; };

View file

@ -1,5 +1,3 @@
#pragma once
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>

View file

@ -23,7 +23,7 @@ void VertexArray::AddBuffer(const VertexBuffer &vb, const VertexBufferLayout& la
{ {
const auto &element = elements[i]; const auto &element = elements[i];
GLCall(glEnableVertexAttribArray(i)); GLCall(glEnableVertexAttribArray(i));
GLCall(glVertexAttribPointer(i, elements[i].count, element.type,element.normalized, layout.GetStride(), (const void*)offset)); GLCall(glVertexAttribPointer(i, elements[i].count, element.type,element.normalized, layout.GetStride(), (const void*) &offset));
offset+=element.count * VertexBufferElement::GetSizeOfType(element.type); offset+=element.count * VertexBufferElement::GetSizeOfType(element.type);
} }
} }