Skip to content

Commit

Permalink
Fixes for Raspberry Pi 2
Browse files Browse the repository at this point in the history
  • Loading branch information
petewarden committed May 10, 2015
1 parent 274366f commit c633163
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
11 changes: 9 additions & 2 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CPPFLAGS=

.PRECIOUS: %.cdat

LIBCPPFLAGS=-Ofast -I ./src/lib/include -I ./src/lib/graph -I ./src/lib/math -I ./src/lib/third_party -I ./src/lib/utility -I ./src/lib/svm -I ./src/lib/opengl -I ./src/lib -I ./src/include
LIBCPPFLAGS=-Ofast -I ./src/lib/include -I ./src/lib/graph -I ./src/lib/math -I ./src/lib/third_party -I ./src/lib/utility -I ./src/lib/svm -I ./src/lib/opengl -I ./src/lib -I ./src/include -g
LIBLDFLAG=
LIBLDLIBS=

Expand Down Expand Up @@ -42,6 +42,13 @@ LIBCPPFLAGS += \
-I./src/lib/pi
endif

ifeq ($(TARGET),pi2)
LIBCPPFLAGS += \
-mcpu=cortex-a7 \
-mfpu=neon-vfpv4 \
-mfloat-abi=hard
endif

ifeq ($(GEMM),pigl)
LIBCPPFLAGS += \
-I/usr/include \
Expand All @@ -63,7 +70,7 @@ ASMOBJS := $(subst .asm,.do,$(ASMSRCS))
LIBOBJS += $(ASMOBJS)
endif

TOOLCPPFLAGS := -O3 -I ./src/include
TOOLCPPFLAGS := -O3 -I ./src/include -g

TOOLSRCS := $(shell find src/tool -name '*.cpp' -not -name '._*')
TOOLOBJS := $(subst .cpp,.o,$(TOOLSRCS))
Expand Down
13 changes: 12 additions & 1 deletion source/src/lib/graph/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include "mailbox.h"
#endif // TARGET_PI

#ifdef USE_EIGEN_GEMM
#include <Eigen/Core>
#endif // USE_EIGEN_GEMM

static void buffer_do_save_to_image_file(Buffer* buffer, const char* filename);

Buffer::Buffer(const Dimensions& dims) :
Expand All @@ -51,6 +55,8 @@ Buffer::Buffer(const Dimensions& dims) :
}
_gpuMemoryBase = mem_lock(_gpuMemoryHandle);
_data = (jpfloat_t*)(mapmem(_gpuMemoryBase + GPU_MEM_MAP, byteCount));
#elif defined(USE_EIGEN_GEMM)
_data = (jpfloat_t*)(Eigen::internal::aligned_malloc(byteCount));
#else // TARGET_PI
_data = (jpfloat_t*)(malloc(byteCount * 1));
#endif // TARGET_PI
Expand Down Expand Up @@ -114,8 +120,10 @@ Buffer::Buffer(const Dimensions& dims, jpfloat_t min, jpfloat_t max, int bitsPer
}
_gpuMemoryBase = mem_lock(_gpuMemoryHandle);
_quantizedData = (char*)(mapmem(_gpuMemoryBase + GPU_MEM_MAP, byteCount));
#elif defined(USE_EIGEN_GEMM)
_quantizedData = (void*)(Eigen::internal::aligned_malloc(byteCount));
#else // TARGET_PI
_quantizedData = (void*)(malloc(byteCount * 1));
_quantizedData = (void*)(malloc(byteCount));
#endif // TARGET_PI
_doesOwnData = true;
setName("None");
Expand All @@ -137,6 +145,9 @@ Buffer::~Buffer()
}
mem_unlock(_gpuMemoryHandle);
mem_free(_gpuMemoryHandle);
#elif defined(USE_EIGEN_GEMM)
Eigen::internal::aligned_free(_data);
Eigen::internal::aligned_free(_quantizedData);
#else // TARGET_PI
free(_data);
free(_quantizedData);
Expand Down
8 changes: 8 additions & 0 deletions source/src/lib/math/matrix_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ void cblas_sgemm_fixed(
posix_memalign((void**)(&aSubMatrix), 16, bytesPerSubMatrix);
jpfloat_t* cSubMatrix;
posix_memalign((void**)(&cSubMatrix), 16, bytesPerSubMatrix);
#elif defined(USE_EIGEN_GEMM)
jpfloat_t* aSubMatrix = (jpfloat_t*)(Eigen::internal::aligned_malloc(bytesPerSubMatrix));
jpfloat_t* cSubMatrix = (jpfloat_t*)(Eigen::internal::aligned_malloc(bytesPerSubMatrix));
#else // TARGET_PI
jpfloat_t* aSubMatrix = (jpfloat_t*)(malloc(bytesPerSubMatrix));
jpfloat_t* cSubMatrix = (jpfloat_t*)(malloc(bytesPerSubMatrix));
Expand Down Expand Up @@ -576,8 +579,13 @@ void cblas_sgemm_fixed(
#endif // USE_EIGEN_GEMM
}

#if defined(USE_EIGEN_GEMM)
Eigen::internal::aligned_free(aSubMatrix);
Eigen::internal::aligned_free(cSubMatrix);
#else // USE_EIGEN_GEMM
free(aSubMatrix);
free(cSubMatrix);
#endif // USE_EIGEN_GEMM
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion source/src/lib/pi/qpu_gemm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef USE_QPU_GEMM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -13,7 +14,7 @@
#define NUM_QPUS (12)
#define NUM_MESSAGE_VALUES (2)

//#define DO_LOG_OPERATIONS


extern uint32_t g_gemm_8bitCode[];
extern size_t g_gemm_8bitCodeByteCount;
Expand Down Expand Up @@ -451,3 +452,5 @@ fprintf(stderr, "\n");
delete outputGPU;
delete input;
}

#endif // USE_QPU_GEMM

0 comments on commit c633163

Please sign in to comment.