From 61402f7b00d9b121196bde6f33b662eb35a10f22 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Fri, 18 Oct 2013 11:08:44 +0200 Subject: [PATCH] First commit (Basic bsp setup) --- .gitignore | 3 +++ CMakeLists.txt | 20 ++++++++++++++++++++ README.md | 7 +++++++ include/bsp.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 include/bsp.hpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41fbad7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build* +*user + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5dbee2b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required (VERSION 2.6) + +include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/include/") + +option(MultiCoreBSP "Building with Multi Core BSP" OFF) +if(MultiCoreBSP) + # setup for my mac + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(libs mcbsp1.1.0 m pthread) + add_definitions( -DUSE_MCBSP ) +else() + # setup for cartesius + set(libs bsponmpi m) +endif() + +find_package(Boost REQUIRED COMPONENTS program_options) +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) +set(libs ${libs} ${Boost_LIBRARIES}) + +add_subdirectory("wavelet") diff --git a/README.md b/README.md new file mode 100644 index 0000000..5196638 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +jcmp +==== + +My very own image compression format. Made during a course on parallel +computing. There will be a sequential and parallel version. The git repo is +extracted from the homework repo, and may contain some unrelated things. + diff --git a/include/bsp.hpp b/include/bsp.hpp new file mode 100644 index 0000000..3ef4574 --- /dev/null +++ b/include/bsp.hpp @@ -0,0 +1,42 @@ +#pragma once + +extern "C" { + #ifdef USE_MCBSP + #include + #else + #include "bsp.h" + #define MCBSP_PROCESSOR_INDEX_DATATYPE int + #define MCBSP_BYTESIZE_TYPE int + #endif +} + +namespace bsp { + typedef MCBSP_PROCESSOR_INDEX_DATATYPE processor_index; + typedef MCBSP_BYTESIZE_TYPE size_type; + + inline void begin(processor_index P) { bsp_begin(P); } + inline void end() { bsp_end(); } + inline void init(void (*spmd)(), int argc, char ** argv){ bsp_init(spmd, argc, argv); } + inline processor_index nprocs() { return bsp_nprocs(); } + inline processor_index pid() { return bsp_pid(); } + inline double time() { return bsp_time(); } + inline void sync() { bsp_sync(); } + + // As we know the type, we don't bother the programmer with bytes and sizeof. Instead simply use the number of elements. + template + void push_reg(T* value, size_type number = 1) + { bsp_push_reg(static_cast(value), number * sizeof(T)); } + + template + void pop_reg(T* value) + { bsp_pop_reg(static_cast(value)); } + + // The offset too is in terms of number of elements, not bytes. + template + void put(processor_index p, T const * source, T * destination, size_type offset = 0, size_type number = 1) + { bsp_put(p, static_cast(source), static_cast(destination), offset * sizeof(T), number * sizeof(T)); } + + template + void get(processor_index p, T const * source, size_type offset, T * destination, size_type number = 1) + { bsp_get(p, static_cast(source), offset, static_cast(destination), number * sizeof(T)); } +}