Refactor
* Changed types.hpp from cpu into platform package
This commit is contained in:
parent
98e52f2579
commit
19299adced
10 changed files with 42 additions and 112 deletions
|
@ -1,7 +1,7 @@
|
|||
#include <iostream>
|
||||
|
||||
inline unsigned long getTimestamp(){
|
||||
unsigned hi,lo;
|
||||
unsigned long hi,lo;
|
||||
asm ("rdtsc": "=a" (lo), "=d" (hi) );
|
||||
return ((unsigned long) lo ) | ((unsigned long) hi << 32);
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ int main(void){
|
|||
unsigned long t2=getTimestamp();
|
||||
std::cout << "Hello 1 -- " << t1 <<std::endl;
|
||||
std::cout << "Hello 2 -- " << t2 <<std::endl;
|
||||
std::cout << "Hello 3 -- " << getTimestamp() <<std::endl;
|
||||
std::cout << "Hello 4 -- " << getTimestamp() <<std::endl;
|
||||
//std::cout << "Hello 3 -- " << getTimestamp() <<std::endl;
|
||||
//std::cout << "Hello 4 -- " << getTimestamp() <<std::endl;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../cpu/types.hpp"
|
||||
#include "../platform/types.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../cpu/types.hpp"
|
||||
#include "../platform/types.hpp"
|
||||
|
||||
namespace BMath
|
||||
{
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
int cmp_swap(int* old_int,int new_int){
|
||||
|
||||
int cmp_swap(int *old_int, int new_int)
|
||||
{
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#include "naive.hpp"
|
||||
#include "types.hpp"
|
||||
#include <iostream>
|
||||
|
||||
void cpu::Naive::add_128(UInt *a,UInt *b){
|
||||
void cpu::Naive::add_128(UInt *a, UInt *b)
|
||||
{
|
||||
ULong a1 = ((ULong)a[0] << 32) | a[1];
|
||||
ULong a2 = ((ULong)a[2] << 32) | a[3];
|
||||
ULong b1 = ((ULong)b[0] << 32) | b[1];
|
||||
|
@ -17,20 +17,18 @@ void cpu::Naive::add_128(UInt *a,UInt *b){
|
|||
a[3] = (UInt)(a2 >> 32);
|
||||
};
|
||||
|
||||
void cpu::Naive::add_256(UInt *a,UInt *b){
|
||||
void cpu::Naive::add_256(UInt *a, UInt *b)
|
||||
{
|
||||
ULong a1 = ((ULong)a[0] << 32) | a[1];
|
||||
ULong a2 = ((ULong)a[2] << 32) | a[3];
|
||||
ULong a3 = ((ULong)a[4] << 32) | a[5];
|
||||
ULong a4 = ((ULong)a[6] << 32) | a[7];
|
||||
|
||||
|
||||
ULong b1 = ((ULong)b[0] << 32) | b[1];
|
||||
ULong b2 = ((ULong)b[2] << 32) | b[3];
|
||||
ULong b3 = ((ULong)b[4] << 32) | b[5];
|
||||
ULong b4 = ((ULong)b[6] << 32) | b[7];
|
||||
|
||||
|
||||
|
||||
a1 = a1 + b1;
|
||||
a2 = a2 + b2;
|
||||
a3 = a3 + b3;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hpp"
|
||||
#include "../platform/types.hpp"
|
||||
namespace cpu
|
||||
{
|
||||
class Naive
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hpp"
|
||||
#include "../platform/types.hpp"
|
||||
|
||||
namespace cpu
|
||||
{
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
/*
|
||||
* Types for x86 architectures
|
||||
*/
|
||||
#ifdef ARCH_X86
|
||||
// Signed type alias
|
||||
typedef int Int;
|
||||
typedef long Long;
|
||||
typedef char Char;
|
||||
typedef short Short;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Int value : 31;
|
||||
Int signal : 1;
|
||||
} int_with_msb;
|
||||
Int signed_int;
|
||||
} SignedInt;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Long value : 63;
|
||||
Int signal : 1;
|
||||
} long_with_msb;
|
||||
} SignedLong;
|
||||
|
||||
// IEEE floating point alias
|
||||
typedef float Float;
|
||||
typedef double Double;
|
||||
|
||||
// Unsigned type alias
|
||||
typedef unsigned char UChar;
|
||||
typedef unsigned short UShort;
|
||||
typedef unsigned int UInt;
|
||||
typedef unsigned long int ULong;
|
||||
|
||||
// SSE DataTypes
|
||||
#define CHAR_LEN_128 16
|
||||
#define CHAR_LEN_256 32
|
||||
|
||||
#define INT_LEN_64 2
|
||||
#define INT_LEN_128 4
|
||||
#define INT_LEN_256 8
|
||||
#define INT_LEN_512 16
|
||||
|
||||
#define LONG_LEN_64 1
|
||||
#define LONG_LEN_128 2
|
||||
#define LONG_LEN_256 4
|
||||
#define LONG_LEN_512 8
|
||||
|
||||
// Masks
|
||||
#define MASK_32 0xFFFFFFFF
|
||||
#define MASK_16 0xFFFF
|
||||
#define MASK_8 0xFF
|
||||
|
||||
// Shifts
|
||||
#define SHIFT_32 32
|
||||
#define SHIFT_16 16
|
||||
#define SHIFT_8 8
|
||||
#endif
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include "types.hpp"
|
||||
#include "../platform/types.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -67,4 +67,4 @@ namespace cpu
|
|||
packedUInteger[3] = packedULong[1] >> SHIFT_32;
|
||||
};
|
||||
};
|
||||
}; // namespace Cpu
|
||||
};
|
|
@ -3,9 +3,8 @@
|
|||
#include "../../platform/platform.hpp"
|
||||
|
||||
#ifdef ARCH_X86
|
||||
#include "../types.hpp"
|
||||
#include "../../platform/types.hpp"
|
||||
#include "../simd.hpp"
|
||||
|
||||
namespace cpu
|
||||
{
|
||||
class SSE: public SIMD
|
||||
|
|
Loading…
Reference in a new issue