diff --git a/CppCmds.make b/CppCmds.make deleted file mode 100644 index 1c39a46..0000000 --- a/CppCmds.make +++ /dev/null @@ -1,222 +0,0 @@ -# GNU Make project makefile autogenerated by Premake - -ifndef config - config=debug -endif - -ifndef verbose - SILENT = @ -endif - -.PHONY: clean prebuild prelink - -ifeq ($(config),debug) - RESCOMP = windres - TARGETDIR = bin/Debug - TARGET = $(TARGETDIR)/CppCmds - OBJDIR = obj/Debug - DEFINES += -DDEBUG -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ - INCLUDES += -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0 -I/usr/include/wx-3.0 - FORCE_INCLUDE += - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lglfw3 - LDDEPS += - ALL_LDFLAGS += $(LDFLAGS) - LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) - define PREBUILDCMDS - endef - define PRELINKCMDS - endef - define POSTBUILDCMDS - endef -all: prebuild prelink $(TARGET) - @: - -endif - -ifeq ($(config),release) - RESCOMP = windres - TARGETDIR = bin/Release - TARGET = $(TARGETDIR)/CppCmds - OBJDIR = obj/Release - DEFINES += -DNDEBUG -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ - INCLUDES += -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0 -I/usr/include/wx-3.0 - FORCE_INCLUDE += - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2 - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2 - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lglfw3 - LDDEPS += - ALL_LDFLAGS += $(LDFLAGS) -s - LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) - define PREBUILDCMDS - endef - define PRELINKCMDS - endef - define POSTBUILDCMDS - endef -all: prebuild prelink $(TARGET) - @: - -endif - -OBJECTS := \ - $(OBJDIR)/complex.o \ - $(OBJDIR)/complex1.o \ - $(OBJDIR)/math.o \ - $(OBJDIR)/math1.o \ - $(OBJDIR)/avx2.o \ - $(OBJDIR)/sse.o \ - $(OBJDIR)/naive.o \ - $(OBJDIR)/sse1.o \ - $(OBJDIR)/gui1.o \ - $(OBJDIR)/ex1.o \ - $(OBJDIR)/ex2.o \ - $(OBJDIR)/model.o \ - $(OBJDIR)/volatile.o \ - $(OBJDIR)/IndexBuffer.o \ - $(OBJDIR)/Renderer.o \ - $(OBJDIR)/Shader.o \ - $(OBJDIR)/VertexArray.o \ - $(OBJDIR)/VertexBuffer.o \ - $(OBJDIR)/VertexBufferLayout.o \ - $(OBJDIR)/gl1.o \ - $(OBJDIR)/gl2.o \ - $(OBJDIR)/gl3.o \ - $(OBJDIR)/utils.o \ - -RESOURCES := \ - -CUSTOMFILES := \ - -SHELLTYPE := posix -ifeq (.exe,$(findstring .exe,$(ComSpec))) - SHELLTYPE := msdos -endif - -$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR) - @echo Linking CppCmds - $(SILENT) $(LINKCMD) - $(POSTBUILDCMDS) - -$(CUSTOMFILES): | $(OBJDIR) - -$(TARGETDIR): - @echo Creating $(TARGETDIR) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(TARGETDIR) -else - $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) -endif - -$(OBJDIR): - @echo Creating $(OBJDIR) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif - -clean: - @echo Cleaning CppCmds -ifeq (posix,$(SHELLTYPE)) - $(SILENT) rm -f $(TARGET) - $(SILENT) rm -rf $(OBJDIR) -else - $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) - $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) -endif - -prebuild: - $(PREBUILDCMDS) - -prelink: - $(PRELINKCMDS) - -ifneq (,$(PCH)) -$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) -$(GCH): $(PCH) | $(OBJDIR) - @echo $(notdir $<) - $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" -else -$(OBJECTS): | $(OBJDIR) -endif - -$(OBJDIR)/complex.o: src/bmath/complex.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/complex1.o: src/bmath/demos/complex.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/math.o: src/bmath/demos/math.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/math1.o: src/bmath/math.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/avx2.o: src/cpu/avx2.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/sse.o: src/cpu/demos/sse.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/naive.o: src/cpu/naive.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/sse1.o: src/cpu/sse.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/gui1.o: src/gui/gui1.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/ex1.o: src/misc/dec/ex1.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/ex2.o: src/misc/dec/ex2.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/model.o: src/misc/memory/model.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/volatile.o: src/misc/memory/volatile.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/IndexBuffer.o: src/opengl/IndexBuffer.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/Renderer.o: src/opengl/Renderer.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/Shader.o: src/opengl/Shader.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/VertexArray.o: src/opengl/VertexArray.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/VertexBuffer.o: src/opengl/VertexBuffer.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/VertexBufferLayout.o: src/opengl/VertexBufferLayout.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/gl1.o: src/opengl/gl1.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/gl2.o: src/opengl/gl2.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/gl3.o: src/opengl/gl3.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/utils.o: src/opengl/utils.cpp - @echo $(notdir $<) - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" - --include $(OBJECTS:%.o=%.d) -ifneq (,$(PCH)) - -include $(OBJDIR)/$(notdir $(PCH)).d -endif \ No newline at end of file diff --git a/src/misc/memory/cautofree.c b/app/cautofree.c similarity index 91% rename from src/misc/memory/cautofree.c rename to app/cautofree.c index 3798a79..4d1c019 100644 --- a/src/misc/memory/cautofree.c +++ b/app/cautofree.c @@ -1,6 +1,6 @@ #include #include -#include "../../../include/misc/memory/util.h" +#include "../memory/util.h" #define AUTO_FREE __attribute__((cleanup(scoped_free))) diff --git a/src/misc/memory/cmem.c b/app/cmem.c similarity index 94% rename from src/misc/memory/cmem.c rename to app/cmem.c index 4e20fcd..09e41ae 100644 --- a/src/misc/memory/cmem.c +++ b/app/cmem.c @@ -1,6 +1,6 @@ #include #include -#include "../../../include/misc/memory/util.h" +#include "../memory/util.h" void stack_frame2(void) { diff --git a/src/bmath/demos/complex.cpp b/app/cnumbers.cpp similarity index 86% rename from src/bmath/demos/complex.cpp rename to app/cnumbers.cpp index e542c17..81ae648 100644 --- a/src/bmath/demos/complex.cpp +++ b/app/cnumbers.cpp @@ -1,5 +1,5 @@ #include -#include "../complex.hpp" +#include "../bmath/complex.hpp" using BMath::Complex; diff --git a/src/misc/dec/ex1.cpp b/app/ex1.cpp similarity index 100% rename from src/misc/dec/ex1.cpp rename to app/ex1.cpp diff --git a/src/misc/dec/ex2.cpp b/app/ex2.cpp similarity index 100% rename from src/misc/dec/ex2.cpp rename to app/ex2.cpp diff --git a/src/opengl/gl1.cpp b/app/gl1.cpp similarity index 90% rename from src/opengl/gl1.cpp rename to app/gl1.cpp index 01b27d6..f9bb828 100644 --- a/src/opengl/gl1.cpp +++ b/app/gl1.cpp @@ -6,12 +6,12 @@ #include #include -#include "Shader.h" -#include "Renderer.h" -#include "VertexBuffer.h" -#include "IndexBuffer.h" -#include "VertexArray.h" -#include "utils.h" +#include "../opengl/Shader.h" +#include "../opengl/Renderer.h" +#include "../opengl/VertexBuffer.h" +#include "../opengl/IndexBuffer.h" +#include "../opengl/VertexArray.h" +#include "../opengl/utils.h" const std::string SHADERS_PATH = "src/opengl/res/shaders/Basic.shader"; diff --git a/src/opengl/gl2.cpp b/app/gl2.cpp similarity index 100% rename from src/opengl/gl2.cpp rename to app/gl2.cpp diff --git a/src/opengl/gl3.cpp b/app/gl3.cpp similarity index 98% rename from src/opengl/gl3.cpp rename to app/gl3.cpp index 0789f38..be102a3 100644 --- a/src/opengl/gl3.cpp +++ b/app/gl3.cpp @@ -74,8 +74,8 @@ void printString(char *s) void display(void) { GLfloat white[3] = {1.0, 1.0, 1.0}; - const char* p1="LINDA MERDA"; - const char* p2="PUTA MERDA"; + const char* p1="KIE KIE"; + const char* p2="DIRI RIIR"; glClear(GL_COLOR_BUFFER_BIT); glColor3fv(white); diff --git a/src/gui/gui1.cpp b/app/gui1.cpp similarity index 100% rename from src/gui/gui1.cpp rename to app/gui1.cpp diff --git a/src/bmath/demos/math.cpp b/app/math.cpp similarity index 94% rename from src/bmath/demos/math.cpp rename to app/math.cpp index 77c2e62..1c48bf8 100644 --- a/src/bmath/demos/math.cpp +++ b/app/math.cpp @@ -1,4 +1,4 @@ -#include "../math.hpp" +#include "../bmath/math.hpp" #include using namespace BMath; diff --git a/src/cpu/demos/sse.cpp b/app/sse.cpp similarity index 85% rename from src/cpu/demos/sse.cpp rename to app/sse.cpp index d5c3199..7f3e1a5 100644 --- a/src/cpu/demos/sse.cpp +++ b/app/sse.cpp @@ -1,7 +1,7 @@ #include -#include "../utils.hpp" -#include "../sse.hpp" -#include "../naive.hpp" +#include "../src/cpu/utils.hpp" +#include "../src/cpu/x86/sse.hpp" +#include "../src/cpu/naive.hpp" #include using namespace cpu; @@ -17,6 +17,7 @@ long int gettime(){ #define MAX_ITER 1000*1000*100 int main(int argc, char** argcv){ + SSE sse = SSE(); UInt v1_128[INT_LEN_128] = { 0x1, 0x2,0x3,0x4 }; UInt v2_128[INT_LEN_128] = { 0x1, 0x2,0x3,0x4 }; @@ -26,7 +27,7 @@ int main(int argc, char** argcv){ Utils::int128BitToLong(v1_128,v1_128_l); Utils::int128BitToLong(v2_128,v2_128_l); - SSE::paddw(v1_128,v2_128); + sse.add_128(v1_128,v2_128); long int start,end; @@ -45,14 +46,14 @@ int main(int argc, char** argcv){ start = gettime(); for(int i=0;i>32; - a[1]=a1; - a[2]=a2>>32; - a[3]=a2; + a[0]=(UInt)a1; + a[1]=(UInt)(a1>>32); + a[2]=(UInt)a2; + a[3]=(UInt)(a2>>32); }; \ No newline at end of file diff --git a/src/cpu/naive.hpp b/src/cpu/naive.hpp index f5999af..db72f6b 100644 --- a/src/cpu/naive.hpp +++ b/src/cpu/naive.hpp @@ -3,10 +3,10 @@ #include "types.hpp" namespace cpu { -class Naive -{ -public: - //Methods - static void sum_128_long(UInt *a, UInt *b); -}; + class Naive + { + public: + // Methods + static void sum_128_long(UInt *a, UInt *b); + }; }; \ No newline at end of file diff --git a/src/cpu/simd.hpp b/src/cpu/simd.hpp new file mode 100644 index 0000000..5076b3e --- /dev/null +++ b/src/cpu/simd.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "types.hpp" + +namespace cpu +{ + class SIMD + { + public: + virtual void add_128(UInt *a, UInt *b)=0; + virtual void add_128(ULong *a, ULong *b)=0; + }; +}; \ No newline at end of file diff --git a/src/cpu/sse.hpp b/src/cpu/sse.hpp deleted file mode 100644 index 237d9d4..0000000 --- a/src/cpu/sse.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "types.hpp" - - -namespace cpu -{ -class SSE -{ -public: - static void paddw(UInt *a, UInt *b); - static void paddd(ULong *a, ULong *b); -}; -}; \ No newline at end of file diff --git a/src/cpu/types.hpp b/src/cpu/types.hpp index 4f0ebc6..a09c17c 100644 --- a/src/cpu/types.hpp +++ b/src/cpu/types.hpp @@ -1,58 +1,64 @@ #pragma once + +#include "../platform/platform.hpp" /* - * Types for x86 architectures - */ -#if defined(__x86_64__) -//Signed type alias -typedef int Int; -typedef long Long; -typedef char Char; -typedef short Short; + * 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 + typedef union { - Int value : 31; - Int signal : 1; - } int_with_msb; - Int signed_int; -} SignedInt; + 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; + typedef union + { + struct + { + Long value : 63; + Int signal : 1; + } long_with_msb; + } SignedLong; -//IEEE floating point alias -typedef float Float; -typedef double Double; + // 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 ULong; + // Unsigned type alias + typedef unsigned char UChar; + typedef unsigned short UShort; + typedef unsigned int UInt; + typedef unsigned long ULong; -//SSE DataTypes -#define INT_LEN_64 2 -#define INT_LEN_128 4 -#define INT_LEN_256 8 -#define INT_LEN_512 16 + // SSE DataTypes + #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 + #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 + // 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 -//Shifts -#define SHIFT_32 32 -#define SHIFT_16 16 -#define SHIFT_8 8 -#endif \ No newline at end of file diff --git a/src/cpu/utils.hpp b/src/cpu/utils.hpp index 4c9590a..ea1e274 100644 --- a/src/cpu/utils.hpp +++ b/src/cpu/utils.hpp @@ -7,44 +7,44 @@ using namespace std; namespace cpu { -class Utils -{ -public: - template - static void printHex(Number *num, Int len) + class Utils { - for (int i = 0; i < len; i++) + public: + template + static void printHex(Number *num, Int len) { - cout << hex << num[i]; - if (i < len - 1) + for (int i = 0; i < len; i++) { - cout << ","; + cout << hex << num[i]; + if (i < len - 1) + { + cout << ","; + } } - } - cout << std::dec << endl; - }; + cout << std::dec << endl; + }; - /** - * Utility method to convert a packaged 128bit int to 128bit long - */ - static void int128BitToLong(UInt *packedUInteger, ULong *packedULong) - { - packedULong[0] = (ULong)packedUInteger[1] << 32 | packedUInteger[0]; - packedULong[1] = (ULong)packedUInteger[3] << 32 | packedUInteger[2]; - }; + /** + * Utility method to convert a packaged 128bit int to 128bit long + */ + static void int128BitToLong(UInt *packedUInteger, ULong *packedULong) + { + packedULong[0] = (ULong)packedUInteger[1] << 32 | packedUInteger[0]; + packedULong[1] = (ULong)packedUInteger[3] << 32 | packedUInteger[2]; + }; - /** - * Utility method to convert a packed 128bit long into a 128 int - */ - static void long128BitToInt(ULong *packedULong, UInt *packedUInteger) - { - //Unpack first long - packedUInteger[0] = packedULong[0] & MASK_32; - packedUInteger[1] = packedULong[0] >> SHIFT_32; + /** + * Utility method to convert a packed 128bit long into a 128 int + */ + static void long128BitToInt(ULong *packedULong, UInt *packedUInteger) + { + // Unpack first long + packedUInteger[0] = packedULong[0] & MASK_32; + packedUInteger[1] = packedULong[0] >> SHIFT_32; - //Unpack second long - packedUInteger[2] = packedULong[1] & MASK_32; - packedUInteger[3] = packedULong[1] >> SHIFT_32; + // Unpack second long + packedUInteger[2] = packedULong[1] & MASK_32; + packedUInteger[3] = packedULong[1] >> SHIFT_32; + }; }; -}; }; // namespace Cpu \ No newline at end of file diff --git a/src/cpu/sse.cpp b/src/cpu/x86/sse.cpp similarity index 81% rename from src/cpu/sse.cpp rename to src/cpu/x86/sse.cpp index 522622d..847f632 100644 --- a/src/cpu/sse.cpp +++ b/src/cpu/x86/sse.cpp @@ -1,8 +1,9 @@ #include "sse.hpp" +#ifdef ARCH_X86 #include //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::add_128(UInt *a,UInt *b) { asm( "movdqa %0, %%xmm1\n" "paddw %1, %%xmm1\n" @@ -14,7 +15,7 @@ void cpu::SSE::paddw(UInt *a,UInt *b) { //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::add_128(ULong *a,ULong *b) { asm( "movdqa %0, %%xmm1\n" "paddd %1, %%xmm1\n" @@ -22,4 +23,5 @@ void cpu::SSE::paddd(ULong *a,ULong *b) { : "=m"(*a) : "m"(*b) ); -}; \ No newline at end of file +}; +#endif \ No newline at end of file diff --git a/src/cpu/x86/sse.hpp b/src/cpu/x86/sse.hpp new file mode 100644 index 0000000..9cff8e5 --- /dev/null +++ b/src/cpu/x86/sse.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "../../platform/platform.hpp" + +#ifdef ARCH_X86 + #include "../types.hpp" + #include "../simd.hpp" + + namespace cpu + { + class SSE: public SIMD + { + public: + void add_128(UInt *a, UInt *b); + void add_128(ULong *a, ULong *b); + }; + }; +#endif \ No newline at end of file diff --git a/src/misc/memory/model.cpp b/src/misc/memory/model.cpp index c87086d..8e9785e 100644 --- a/src/misc/memory/model.cpp +++ b/src/misc/memory/model.cpp @@ -73,31 +73,4 @@ void printPointByRef(Point2D *point){ template void printBoxContent(Box box){ print("Box: Content: " << *box << ":" << box << ":" << box.getRefCounter()) -} - -int main(void) -{ - print("Stack memory management") - Point2D p1={1,2}; - printPointByValue(p1); - print("") - - print("Heap memory management") - Point2D *p2 = new Point2D{3, 4}; - printPointByRef(p2); - delete p2; - print("") - - print("Heap/Stack memory management") - Point2D *ptrPt3 = new Point2D(10,20); - Box> box1(ptrPt3); - print(box1) - print("")print("") - - printBoxContent(box1); - Box> box2=box1; - printBoxContent(box2); - Atomic atomic_int(12); - - return 0; } \ No newline at end of file diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp new file mode 100644 index 0000000..b287822 --- /dev/null +++ b/src/platform/platform.hpp @@ -0,0 +1,19 @@ +#pragma once + +// Check for architecture +#ifdef __i386 +#define ARCH_X86 +#endif + +#ifdef __x86__ +#define ARCH_X86 +#endif + +#ifdef __x64__ +#define ARCH_X86 +#endif + +#ifdef __x86_64__ +#define ARCH_X86 +#endif +