Commit 4a4c8ba5 authored by incardon's avatar incardon

First commit OpenFPM_devices

parents
This diff is collapsed.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([src/main.cpp])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([src/config.h])
m4_ifdef([MYSQL_FOUND],,[m4_include([m4/ax_lib_mysql.m4])])
m4_ifdef([AX_CHECK_COMPILER_FLAGS],,[m4_include([m4/ax_check_compiler_flags.m4])])
m4_ifdef([ACX_PTHREAD],,[m4_include([m4/acx_pthread.m4])])
m4_ifdef([AX_CHECK_CL],,[m4_include([m4/ax_opencl.m4])])
m4_ifdef([AX_BOOST_BASE],,[m4_include([m4/ax_boost_base.m4])])
m4_ifdef([AX_BOOST_PROGRAM_OPTIONS],,[m4_include([m4/ax_boost_program_options.m4])])
m4_ifdef([AX_BOOST_THREAD],,[m4_include([m4/ax_boost_thread.m4])])
m4_ifdef([ACX_MPI],,[m4_include([m4/acx_mpi.m4])])
m4_ifdef([AX_OPENMP],,[m4_include([m4/ax_openmp.m4])])
m4_ifdef([AX_GCC_X86_CPUID],,[m4_include([m4/ax_gcc_x86_cpuid.m4])])
m4_ifdef([AX_GCC_ARCHFLAG],,[m4_include([m4/ax_gcc_archflag.m4])])
m4_ifdef([AX_CUDA],,[m4_include([m4/ax_cuda.m4])])
CXXFLAGS+=" --std=c++11 "
NVCCFLAGS=" "
# Checks for programs.
AC_PROG_CXX
# Checks g++ flags
AC_CANONICAL_HOST
# Check target architetture
AX_GCC_ARCHFLAG([], [CXXFLAGS="$CXXFLAGS $ax_cv_gcc_archflag"], [])
###### Check for debug compilation
AC_MSG_CHECKING(whether to build with debug information)
debuger=no
AC_ARG_ENABLE(debug,
AC_HELP_STRING(
[--enable-debug],
[enable debug data generation (def=no)]
),
debuger="$enableval"
)
AC_MSG_RESULT($debuger)
if test x"$debuger" = x"yes"; then
AC_DEFINE([DEBUG_MODE],[],[Debug])
AC_DEFINE([DEBUG],[],[Debug])
CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 "
NVCCFLAGS+="$NVCCFLAGS -g -O0 "
else
CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 "
NVCCFLAGS+="$NVCCFLAGS -O3 "
fi
####### Checking for GPU support
AX_CUDA
AC_MSG_CHECKING(whether to build with GPU support)
gpu_support=no
AC_ARG_ENABLE(gpu,
AC_HELP_STRING(
[--enable-gpu],
[enable gpu support]
),
gpu_support="$enableval"
)
AC_MSG_RESULT($gpu_support)
if test x"$gpu_support" = x"yes"; then
AC_DEFINE([GPU],[],[GPU support])
fi
# Set this conditional if cuda is wanted
AM_CONDITIONAL(BUILDCUDA, test ! x$NVCC = x"no")
###########################
no_avx=no
no_sse42=no
no_sse41=no
no_sse3=no
no_sse2=no
no_sse=no
no_mmx=no
AX_CHECK_COMPILER_FLAGS([-msse4.2],[CXXFLAGS="$CXXFLAGS -mavx"],[no_avx=yes])
AX_CHECK_COMPILER_FLAGS([-msse4.2],[CXXFLAGS="$CXXFLAGS -msse4.2"],[no_sse42=yes])
AX_CHECK_COMPILER_FLAGS([-msse4.1],[CXXFLAGS="$CXXFLAGS -msse4.1"],[no_sse41=yes])
AX_CHECK_COMPILER_FLAGS([-msse3],[CXXFLAGS="$CXXFLAGS -msse3"],[no_sse3=yes])
AX_CHECK_COMPILER_FLAGS([-msse2],[CXXFLAGS="$CXXFLAGS -msse2"],[no_sse2=yes])
AX_CHECK_COMPILER_FLAGS([-msse],[CXXFLAGS="$CXXFLAGS -msse"],[no_sse=yes])
AX_CHECK_COMPILER_FLAGS([-mmmx],[CXXFLAGS="$CXXFLAGS -mmmx"],[no_mmx=yes])
AX_CHECK_COMPILER_FLAGS([-Wno-unused-but-set-variable],[CXXFLAGS="$CXXFLAGS -Wno-unused-but-set-variable"],[])
AC_SUBST(NVCCFLAGS)
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
echo ""
echo "***********************************"
echo "* *"
arch_str="${ax_cv_gcc_archflag#-march=#-mtune=}"
arch_str="${arch_str#-mtune=}"
n_arch_str=${#arch_str}
for (( X=0; X<23-n_arch_str; X++ ))
do
arch_str="$arch_str "
done
echo "* arch: $arch_str*"
if [ test x"$no_sse42" = x"no" ]; then
echo "* sse4.2: yes *"
else
echo "* sse4.2: no *"
fi
if [ test x"$no_sse41" = x"no" ]; then
echo "* sse4.1: yes *"
else
echo "* sse4.1: no *"
fi
if [ test x"$no_sse3" = x"no" ]; then
echo "* sse3: yes *"
else
echo "* sse3: no *"
fi
if [ test x"$no_sse2" = x"no" ]; then
echo "* sse2: yes *"
else
echo "* sse2: no *"
fi
if [ test x"$no_sse" = x"no" ]; then
echo "* sse: yes *"
else
echo "* sse: no *"
fi
if [ test x"$no_mmx" = x"no" ]; then
echo "* mmx: yes *"
else
echo "* mmx: no *"
fi
if [ test x"$profiler" = x"yes" ]; then
echo "* profiler: yes *"
else
echo "* profiler: no *"
fi
if [ test x"$debuger" = x"yes" ]; then
echo "* debug: yes *"
else
echo "* debug: no *"
fi
if [ test x"$no_64" = x"no" ]; then
echo "* 64 bit: yes *"
else
echo "* 64 bit: no *"
fi
if [ test x"$gpu_support" = x"no" ]; then
echo "* gpu: no *"
else
echo "* gpu: yes *"
fi
echo "* *"
echo "***********************************"
#!/bin/bash
mkdir ${HOME}/MPI
wget http://www.open-mpi.de/software/ompi/v1.8/downloads/openmpi-1.8.1.tar.bz2
tar -xvf openmpi-1.8.1.tar.bz2
cd openmpi-1.8.1
sh ./configure --prefix=${HOME}/MPI --enable-opal-multi-threads --enable-mpi-f90
make
make install
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
bin_PROGRAMS = ppline
ppline_SOURCES = main.cpp
ppline_CXXFLAGS = $(CUDA_CFLAGS)
ppline_CFLAGS = $(CUDA_CFLAGS)
ppline_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/
.cu.o :
$(NVCC) $(NVCCFLAGS) -o $@ -c $<
/*
* cuda_macro.h
*
* Created on: Aug 17, 2014
* Author: Pietro Incardona
*/
#include <iostream>
#define CUDA_SAFE_CALL(call) {\
cudaError_t err = call;\
if (cudaSuccess != err) {\
std::cerr << "Cuda error in file "<< __FILE__ << " in line " << __LINE__ << ": " << cudaGetErrorString(err);\
}\
}
/*
* OpenFPMwdeviceCudaMemory.cu
*
* Created on: Aug 11, 2014
* Author: Pietro Incardona
*/
#include <cstddef>
#include <cuda_runtime.h>
#include "CudaMemory.cuh"
/*! \brief Allocate a chunk of memory
*
* Allocate a chunk of memory
*
* \param sz size of the chunk of memory to allocate in byte
*
*/
bool CudaMemory::allocate(size_t sz)
{
//! Allocate the device memory
if (dm == NULL)
{dv = new boost::shared_ptr<void>(new thrust::device_vector<void>(sz));}
}
void CudaMemory::destroy()
{
dv = NULL;
}
void CudaMemory::copyFromPointer(ThreadWorker t)
{
// check if we have a host buffer, if not allocate it
// put on queue a copy from device to host
t.call();
// put on queue a memory copy from pointers
}
void CudaMemory::copyDeviceToDevice(ThreadWorker t)
{
// put on queue a copy from device to device
t.call();
}
bool CudaMemory::copy(memory m, ThreadWorker t)
{
//! Here we try to cast memory into OpenFPMwdeviceCudaMemory
CudaMemory * ofpm = dynamic_cast<CudaMemory>(m);
//! if we fail we get the pointer and simply copy from the pointer
if (ofpm == NULL)
{
// copy the memory from device to host and from host to device
copyFromPointer(t);
}
else
{
// they are the same memory type, use cuda/thrust buffer copy
copyDeviceToDevice();
}
}
bool CudaMemory::copy(OpenFPMwdeviceCudaMemory m)
{
// they are the same type of memory so copy from device to device
copyDeviceToDevice();
}
size_t CudaMemory::size()
{
dv->size();
}
bool CudaMemory::resize(size_t sz)
{
//! Allocate the device memory
if (dv == NULL)
{dv = new boost::shared_ptr<void>(new thrust::device_vector<void>());}
else
{dv.get()->resize(sz);}
}
/*
* OpenFPMwdeviceCudaMemory.h
*
* Created on: Aug 8, 2014
* Author: Pietro Incardona
*/
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <boost/shared_ptr>
/**
* \brief This class create instructions to allocate, and destroy GPU memory
*
* This class create instructions to allocate, destroy, resize GPU buffer,
* eventually if direct, comunication is not supported, it can instruction
* to create an Host Pinned memory.
*
* Usage:
*
* TO DO
*
* This class in general is used by OpenFPM_data project to basically
* record all the operation made and generate a set of instructions
*
*/
class CudaMemory : public memory
{
//!
//! device memory
void * dm;
//! allocate memory
virtual bool allocate(size_t sz);
//! destroy memory
virtual void destroy();
//! copy memory
virtual bool copy(memory m);
//! the the size of the allocated memory
virtual size_t size();
//! resize the momory allocated
virtual bool resize(size_t sz);
};
#include <iostream.h>
int main()
{
}
#include <cstddef>
#include <cuda_runtime.h>
#include "CudaMemory.cuh"
#include "cuda_macro.h"
/*! \brief Allocate a chunk of memory
*
* Allocate a chunk of memory
*
* \param sz size of the chunk of memory to allocate in byte
*
*/
bool CudaMemory::allocate(size_t sz)
{
//! Allocate the device memory
if (dm == NULL)
{CUDA_SAFE_CALL(cudaAlloc(&dv,sz,cudaAlloc));}
}
/*! \brief destroy a chunk of memory
*
* Destroy a chunk of memory
*
*/
void CudaMemory::destroy()
{
CUDA_SAFE_CALL(cudaDestroy(dv));
}
/*! \brief copy the device memory to a pointer
*
* copy the device memory to a pointer
*
*/
void CudaMemory::copyToPointer()
{
// check if we have a host buffer, if not allocate it
if (hm == NULL)
{CUDA_SAFE_CALL(cudaHostAlloc(&hm,sz*sizeof(T),cudaHostAllocMapped))}
// put on queue a copy from device to host
t.call();
// put on queue a memory copy from pointers
}
void CudaMemory::copyDeviceToDevice()
{
// put on queue a copy from device to device
t.call();
}
bool CudaMemory::copy(memory m)
{
//! Here we try to cast memory into OpenFPMwdeviceCudaMemory
CudaMemory * ofpm = dynamic_cast<CudaMemory>(m);
//! if we fail we get the pointer and simply copy from the pointer
if (ofpm == NULL)
{
// copy the memory from device to host and from host to device
copyFromPointer(t);
}
else
{
// they are the same memory type, use cuda/thrust buffer copy
copyDeviceToDevice();
}
}
bool CudaMemory::copy(OpenFPMwdeviceCudaMemory m)
{
// they are the same type of memory so copy from device to device
copyDeviceToDevice();
}
size_t CudaMemory::size()
{
dv->size();
}
bool CudaMemory::resize(size_t sz)
{
//! Allocate the device memory
if (dv == NULL)
{dv = new boost::shared_ptr<void>(new thrust::device_vector<void>());}
else
{dv.get()->resize(sz);}
}
/*
* CudaMemory.cu
*
* Created on: Aug 17, 2014
* Author: Pietro Incardona
*/
/**
* \brief This class create instructions to allocate, and destroy GPU memory
*
* This class create instructions to allocate, destroy, resize GPU buffer,
* eventually if direct, comunication is not supported, it can instruction
* to create an Host Pinned memory.
*
* Usage:
*
* TO DO
*
* This class in general is used by OpenFPM_data project to basically
* record all the operation made and generate a set of instructions
*
*/
class CudaMemory : public memory
{
//!
//! device memory
void * dm;
//! host memory
void * hm;
//! allocate memory
virtual bool allocate(size_t sz);
//! destroy memory
virtual void destroy();
//! copy memory
virtual bool copy(memory m);
//! the the size of the allocated memory
virtual size_t size();
//! resize the momory allocated
virtual bool resize(size_t sz);
};
/*
* HeapMemory.cpp
*
* Created on: Aug 17, 2014
* Author: Pietro Incardona
*/
#include "HeapMemory.hpp"
/*
* HeapMempory.hpp
*
* Created on: Aug 17, 2014
* Author: Pietro Incardona
*/
class HeapMemory
{
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment