Restructure code
This commit is contained in:
parent
2cdd908a9e
commit
41bdca0161
27 changed files with 50 additions and 14 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -16,3 +16,7 @@ Makefile
|
||||||
build/
|
build/
|
||||||
lib
|
lib
|
||||||
.gitkey
|
.gitkey
|
||||||
|
*.deb
|
||||||
|
*.gz
|
||||||
|
*.Z
|
||||||
|
*Linux.sh
|
||||||
|
|
|
@ -9,6 +9,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
set (CMAKE_CXX_STANDARD 11)
|
set (CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(include)
|
||||||
#add_executable(c_time time.cpp)
|
#add_executable(c_time time.cpp)
|
||||||
|
|
||||||
#install(TARGETS cpplab RUNTIME DESTINATION bin)
|
#install(TARGETS cpplab RUNTIME DESTINATION bin)
|
||||||
|
|
4
include/CMakeLists.txt
Normal file
4
include/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
add_subdirectory(bmath)
|
||||||
|
add_subdirectory(cpu)
|
||||||
|
add_subdirectory(dstruct)
|
||||||
|
add_subdirectory(misc)
|
0
include/bmath/CMakeLists.txt
Normal file
0
include/bmath/CMakeLists.txt
Normal file
0
include/cpu/CMakeLists.txt
Normal file
0
include/cpu/CMakeLists.txt
Normal file
0
include/dstruct/CMakeLists.txt
Normal file
0
include/dstruct/CMakeLists.txt
Normal file
1
include/misc/CMakeLists.txt
Normal file
1
include/misc/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
add_subdirectory(memory)
|
0
include/misc/memory/CMakeLists.txt
Normal file
0
include/misc/memory/CMakeLists.txt
Normal file
|
@ -4,6 +4,11 @@ add_library(
|
||||||
math.cpp
|
math.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_include_directories( bmath
|
||||||
|
PUBLIC
|
||||||
|
"${CMAKE_SOURCE_DIR}/include"
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
complex
|
complex
|
||||||
demos/complex.cpp
|
demos/complex.cpp
|
||||||
|
@ -14,4 +19,8 @@ add_executable(
|
||||||
math
|
math
|
||||||
demos/math.cpp
|
demos/math.cpp
|
||||||
math.cpp
|
math.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS bmath
|
||||||
|
DESTINATION "/usr/lib/bmath"
|
||||||
)
|
)
|
|
@ -1,4 +1,4 @@
|
||||||
#include "complex.hpp"
|
#include "../../include/bmath/complex.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor implementation
|
* Constructor implementation
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../complex.hpp"
|
#include "../../../include/bmath/complex.hpp"
|
||||||
|
|
||||||
using BMath::Complex;
|
using BMath::Complex;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../math.hpp"
|
#include "../../../include/bmath/math.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace BMath;
|
using namespace BMath;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "math.hpp"
|
#include "../../include/bmath/math.hpp"
|
||||||
|
|
||||||
//http://graphics.stanford.edu/~seander/bithacks.html
|
//http://graphics.stanford.edu/~seander/bithacks.html
|
||||||
//https://hbfs.wordpress.com/2008/08/05/branchless-equivalents-of-simple-functions/
|
//https://hbfs.wordpress.com/2008/08/05/branchless-equivalents-of-simple-functions/
|
||||||
|
@ -6,11 +6,12 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <iostream>
|
#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
|
* 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
|
* 0x11111111 --> equals to -1 integer
|
||||||
*/
|
*/
|
||||||
inline Int msb(Int value)
|
Int msb(Int value)
|
||||||
{
|
{
|
||||||
return value >> (CHAR_BIT * sizeof(Int) - 1);
|
return value >> (CHAR_BIT * sizeof(Int) - 1);
|
||||||
};
|
};
|
||||||
|
@ -23,12 +24,13 @@ inline Int msb(Int value)
|
||||||
* More on unions
|
* More on unions
|
||||||
* https://www.geeksforgeeks.org/union-c/
|
* https://www.geeksforgeeks.org/union-c/
|
||||||
*/
|
*/
|
||||||
inline Int msb2(Int value)
|
Int msb2(Int value)
|
||||||
{
|
{
|
||||||
SignedInt sint = {.signed_int = value};
|
SignedInt sint = {.signed_int = value};
|
||||||
return sint.int_with_msb.signal;
|
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));
|
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);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include "avx2.hpp"
|
#include "../../include/cpu/avx2.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../utils.hpp"
|
#include "../../../include/cpu/utils.hpp"
|
||||||
#include "../sse.hpp"
|
#include "../../../include/cpu/sse.hpp"
|
||||||
#include "../naive.hpp"
|
#include "../../../include/cpu/naive.hpp"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
using namespace cpu;
|
using namespace cpu;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "naive.hpp"
|
#include "../../include/cpu/naive.hpp"
|
||||||
#include "types.hpp"
|
#include "../../include/cpu/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){
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "sse.hpp"
|
#include "../../include/cpu/sse.hpp"
|
||||||
#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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "smartpointer.h"
|
#include "../../../include/misc/memory/smartpointer.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#define UPtr std::unique_ptr
|
#define UPtr std::unique_ptr
|
||||||
|
|
Loading…
Reference in a new issue