Restructure code

This commit is contained in:
balhau 2020-07-17 08:46:46 +01:00
parent 2cdd908a9e
commit 41bdca0161
No known key found for this signature in database
GPG key ID: BE6343D39997BF6C
27 changed files with 50 additions and 14 deletions

4
.gitignore vendored
View file

@ -16,3 +16,7 @@ Makefile
build/
lib
.gitkey
*.deb
*.gz
*.Z
*Linux.sh

View file

@ -9,6 +9,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_CXX_STANDARD 11)
add_subdirectory(src)
add_subdirectory(include)
#add_executable(c_time time.cpp)
#install(TARGETS cpplab RUNTIME DESTINATION bin)

4
include/CMakeLists.txt Normal file
View file

@ -0,0 +1,4 @@
add_subdirectory(bmath)
add_subdirectory(cpu)
add_subdirectory(dstruct)
add_subdirectory(misc)

View file

View file

View file

View file

@ -0,0 +1 @@
add_subdirectory(memory)

View file

View file

@ -4,6 +4,11 @@ add_library(
math.cpp
)
target_include_directories( bmath
PUBLIC
"${CMAKE_SOURCE_DIR}/include"
)
add_executable(
complex
demos/complex.cpp
@ -14,4 +19,8 @@ add_executable(
math
demos/math.cpp
math.cpp
)
install(TARGETS bmath
DESTINATION "/usr/lib/bmath"
)

View file

@ -1,4 +1,4 @@
#include "complex.hpp"
#include "../../include/bmath/complex.hpp"
/**
* Constructor implementation

View file

@ -1,5 +1,5 @@
#include <iostream>
#include "../complex.hpp"
#include "../../../include/bmath/complex.hpp"
using BMath::Complex;

View file

@ -1,4 +1,4 @@
#include "../math.hpp"
#include "../../../include/bmath/math.hpp"
#include <iostream>
using namespace BMath;

View file

@ -1,4 +1,4 @@
#include "math.hpp"
#include "../../include/bmath/math.hpp"
//http://graphics.stanford.edu/~seander/bithacks.html
//https://hbfs.wordpress.com/2008/08/05/branchless-equivalents-of-simple-functions/
@ -6,11 +6,12 @@
#include <limits.h>
#include <iostream>
#define C_API extern "C"
/**
* This will get the most significant bit of the Int value. If the most significant bit is 1 then the number is
* 0x11111111 --> equals to -1 integer
*/
inline Int msb(Int value)
Int msb(Int value)
{
return value >> (CHAR_BIT * sizeof(Int) - 1);
};
@ -23,12 +24,13 @@ inline Int msb(Int value)
* More on unions
* https://www.geeksforgeeks.org/union-c/
*/
inline Int msb2(Int value)
Int msb2(Int value)
{
SignedInt sint = {.signed_int = value};
return sint.int_with_msb.signal;
};
/**
*
*/
@ -55,3 +57,18 @@ Int BMath::Math<Int>::max(Int a, Int b)
{
return a + ((b - a) & ~msb2(b - a));
}
/**
* Export as C API
*/
C_API Int c_msb(Int value)
{
return msb(value);
};
C_API Int c_msb2(Int value)
{
return msb2(value);
}

View file

@ -1,4 +1,4 @@
#include "avx2.hpp"
#include "../../include/cpu/avx2.hpp"
#include <iostream>
#include <string>

View file

@ -1,7 +1,7 @@
#include <iostream>
#include "../utils.hpp"
#include "../sse.hpp"
#include "../naive.hpp"
#include "../../../include/cpu/utils.hpp"
#include "../../../include/cpu/sse.hpp"
#include "../../../include/cpu/naive.hpp"
#include <sys/time.h>
using namespace cpu;

View file

@ -1,5 +1,5 @@
#include "naive.hpp"
#include "types.hpp"
#include "../../include/cpu/naive.hpp"
#include "../../include/cpu/types.hpp"
#include <iostream>
void cpu::Naive::sum_128_long(UInt *a,UInt *b){

View file

@ -1,4 +1,4 @@
#include "sse.hpp"
#include "../../include/cpu/sse.hpp"
#include <iostream>
//X86 Assembly to add two 128 bit numbers in the form of packed integers 32bit

View file

@ -1,4 +1,4 @@
#include "smartpointer.h"
#include "../../../include/misc/memory/smartpointer.h"
#include <memory>
#define UPtr std::unique_ptr