Skip to content
Snippets Groups Projects
Commit 62bbbe41 authored by Pietro Incardona's avatar Pietro Incardona
Browse files

Add build jenkins script

parent 453d86e4
No related branches found
No related tags found
No related merge requests found
#! /bin/bash
cd src
sh ./autogen.sh
if [ "$2" == "master" ]
then
sh ./configure --disable-gpu
else
sh ./configure
fi
make
./src/mem
...@@ -7,22 +7,16 @@ AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) ...@@ -7,22 +7,16 @@ AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_SRCDIR([src/main.cpp])
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([src/config.h]) AC_CONFIG_HEADER([src/config/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([ACX_PTHREAD],,[m4_include([m4/acx_pthread.m4])])
m4_ifdef([AX_CHECK_CL],,[m4_include([m4/ax_opencl.m4])]) m4_ifdef([AX_BOOST],,[m4_include([m4/ax_boost.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([ACX_MPI],,[m4_include([m4/acx_mpi.m4])])
m4_ifdef([AX_OPENMP],,[m4_include([m4/ax_openmp.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])]) m4_ifdef([AX_CUDA],,[m4_include([m4/ax_cuda.m4])])
CXXFLAGS+=" --std=c++11 " CXXFLAGS+=" --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter "
NVCCFLAGS=" " NVCCFLAGS=" "
INCLUDES_PATH=" -Iconfig "
# Checks for programs. # Checks for programs.
AC_PROG_CXX AC_PROG_CXX
...@@ -31,9 +25,25 @@ AC_PROG_CXX ...@@ -31,9 +25,25 @@ AC_PROG_CXX
AC_CANONICAL_HOST AC_CANONICAL_HOST
# Check target architetture ###### Check for test coverage
AC_MSG_CHECKING(whether to build with test coverage)
test_cov=no
AC_ARG_ENABLE(test-coverage,
AC_HELP_STRING(
[--enable-test-coverage],
[enable test coverage]
),
test_cov="$enableval"
)
AX_GCC_ARCHFLAG([], [CXXFLAGS="$CXXFLAGS $ax_cv_gcc_archflag"], [])
AC_MSG_RESULT($test_cov)
if test x"$test_cov" = x"yes"; then
AC_DEFINE([TEST_COVERAGE_MODE],[],[Test coverage mode])
CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage "
fi
###### Check for debug compilation ###### Check for debug compilation
...@@ -56,55 +66,52 @@ if test x"$debuger" = x"yes"; then ...@@ -56,55 +66,52 @@ if test x"$debuger" = x"yes"; then
CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 " CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 "
NVCCFLAGS+="$NVCCFLAGS -g -O0 " NVCCFLAGS+="$NVCCFLAGS -g -O0 "
else else
CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 " CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 -funroll-loops "
NVCCFLAGS+="$NVCCFLAGS -O3 " NVCCFLAGS+="$NVCCFLAGS -O3 "
fi fi
##### CHECK FOR BOOST ##############
AX_BOOST([1.52],[],[])
####### Checking for GPU support ####### Checking for GPU support
AX_CUDA AX_CUDA
AC_MSG_CHECKING(whether to build with GPU support) if test x"$NVCC_EXIST" = x"yes"; then
gpu_support=no AC_MSG_CHECKING(whether to build with GPU support)
AC_ARG_ENABLE(gpu, gpu_support=yes
AC_HELP_STRING( AC_ARG_ENABLE(gpu,
[--enable-gpu], AC_HELP_STRING(
[enable gpu support] [--enable-gpu],
), [enable gpu support]
gpu_support="$enableval" ),
) gpu_support="$enableval"
)
AC_MSG_RESULT($gpu_support)
if test x"$gpu_support" = x"yes"; then
AC_DEFINE([CUDA_GPU],[],[CUDA GPU support])
fi
else
gpu_support=no
fi
# Set this conditional if cuda is wanted
AC_MSG_RESULT($gpu_support) #
if test x"$gpu_support" = x"yes"; then
AC_DEFINE([GPU],[],[GPU support])
fi
AM_CONDITIONAL(BUILDCUDA, test x$gpu_support = x"yes")
# Set this conditional if cuda is wanted ##### CHECK FOR BOOST ###
AM_CONDITIONAL(BUILDCUDA, test ! x$NVCC = x"no") AX_BOOST([1.52],[],[])
########################### ##########################
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) AC_SUBST(NVCCFLAGS)
AC_SUBST(INCLUDES_PATH)
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
...@@ -115,59 +122,26 @@ AC_OUTPUT ...@@ -115,59 +122,26 @@ AC_OUTPUT
echo "" echo ""
echo "***********************************" echo "***********************************"
echo "* *" echo "* *"
arch_str="${ax_cv_gcc_archflag#-march=#-mtune=}" if [ test x"$profiler" = x"yes" ]; then
arch_str="${arch_str#-mtune=}" echo "* profiler: yes *"
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 else
echo "* sse: no *" echo "* profiler: no *"
fi fi
if [ test x"$no_mmx" = x"no" ]; then if [ test x"$memcheck" = x"yes" ]; then
echo "* mmx: yes *" echo "* memcheck: yes *"
else else
echo "* mmx: no *" echo "* memcheck: no *"
fi fi
if [ test x"$profiler" = x"yes" ]; then if [ test x"$test_cov" = x"yes" ]; then
echo "* profiler: yes *" echo "* test coverage: yes *"
else else
echo "* profiler: no *" echo "* test coverage: no *"
fi fi
if [ test x"$debuger" = x"yes" ]; then if [ test x"$debuger" = x"yes" ]; then
echo "* debug: yes *" echo "* debug: yes *"
else else
echo "* debug: no *" echo "* debug: no *"
fi 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 if [ test x"$gpu_support" = x"no" ]; then
echo "* gpu: no *" echo "* gpu: no *"
else else
......
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB) LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
bin_PROGRAMS = ppline bin_PROGRAMS = mem
ppline_SOURCES = main.cpp Memleak_check.cpp mem_SOURCES = main.cpp memory/HeapMemory.cpp memory/CudaMemory.cu
ppline_CXXFLAGS = $(CUDA_CFLAGS) mem_CXXFLAGS = $(INCLUDES_PATH)
ppline_CFLAGS = $(CUDA_CFLAGS) mem_CFLAGS =
ppline_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/ mem_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/
.cu.o : .cu.o :
$(NVCC) $(NVCCFLAGS) -o $@ -c $< $(NVCC) $(NVCCFLAGS) -I. $(INCLUDES_PATH) -o $@ -c $<
#include <iostream.h> #include <iostream>
int main() #include "config.h"
{ #define BOOST_TEST_MODULE "C++ test module for OpenFPM_data project"
#include <boost/test/included/unit_test.hpp>
#include "memory/HeapMemory_unit_tests.hpp"
}
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "CudaMemory.cuh" #include "CudaMemory.cuh"
#include "cuda_macro.h" #include "cuda_macro.h"
#include <cstring> #include <cstring>
#include "Memleak_check.hpp"
/*! \brief Allocate a chunk of memory /*! \brief Allocate a chunk of memory
* *
...@@ -35,6 +34,7 @@ void CudaMemory::destroy() ...@@ -35,6 +34,7 @@ void CudaMemory::destroy()
{ {
//! Release the allocated memory //! Release the allocated memory
CUDA_SAFE_CALL(cudaFree(dm)); CUDA_SAFE_CALL(cudaFree(dm));
dm = NULL;
} }
if (hm != NULL) if (hm != NULL)
...@@ -45,6 +45,7 @@ void CudaMemory::destroy() ...@@ -45,6 +45,7 @@ void CudaMemory::destroy()
//! remove hm //! remove hm
check_delete(hm); check_delete(hm);
#endif #endif
hm = NULL;
} }
} }
...@@ -177,23 +178,41 @@ bool CudaMemory::resize(size_t sz) ...@@ -177,23 +178,41 @@ bool CudaMemory::resize(size_t sz)
if (size() == 0) if (size() == 0)
return allocate(sz); return allocate(sz);
//! Create a new buffer if sz is bigger than the actual size
void * thm;
//! Create a new buffer if sz is bigger than the actual size //! Create a new buffer if sz is bigger than the actual size
void * tdm; void * tdm;
if (this->sz < sz) if (dm != NULL)
CUDA_SAFE_CALL(cudaMalloc(&tdm,sz)); {
if (this->sz < sz)
CUDA_SAFE_CALL(cudaMalloc(&tdm,sz));
//! copy from the old buffer to the new one
//! copy from the old buffer to the new one CUDA_SAFE_CALL(cudaMemcpy(tdm,dm,size(),cudaMemcpyDeviceToDevice));
}
CUDA_SAFE_CALL(cudaMemcpy(dm,tdm,size(),cudaMemcpyDeviceToDevice)); if (hm != NULL)
{
if (this->sz < sz)
CUDA_SAFE_CALL(cudaHostAlloc(&thm,sz,cudaHostAllocMapped));
//! copy from the old buffer to the new one
CUDA_SAFE_CALL(cudaMemcpy(thm,hm,size(),cudaMemcpyHostToHost));
}
//! free the old buffer //! free the old buffer
destroy(); destroy();
dm = tdm;
hm = thm;
//! change to the new buffer //! change to the new buffer
dm = tdm;
this->sz = sz; this->sz = sz;
return true; return true;
...@@ -207,21 +226,18 @@ bool CudaMemory::resize(size_t sz) ...@@ -207,21 +226,18 @@ bool CudaMemory::resize(size_t sz)
void * CudaMemory::getPointer() void * CudaMemory::getPointer()
{ {
//| allocate an host memory if not allocated
if (hm == NULL)
allocate_host(sz);
//! if the host buffer is synchronized with the device buffer return the host buffer //! if the host buffer is synchronized with the device buffer return the host buffer
if (is_hm_sync) if (is_hm_sync)
return hm; return hm;
//! we have to synchronize
//| allocate an host mempory
if (hm == NULL)
allocate_host(sz);
//! copy from device to host memory //! copy from device to host memory
CUDA_SAFE_CALL(cudaMemcpy(dm,hm,sz,cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(hm,dm,sz,cudaMemcpyDeviceToHost));
return hm; return hm;
} }
...@@ -50,6 +50,8 @@ class CudaMemory : public memory ...@@ -50,6 +50,8 @@ class CudaMemory : public memory
//! Allocate an host buffer //! Allocate an host buffer
void allocate_host(size_t sz); void allocate_host(size_t sz);
public:
//! allocate memory //! allocate memory
virtual bool allocate(size_t sz); virtual bool allocate(size_t sz);
//! destroy memory //! destroy memory
...@@ -101,7 +103,7 @@ class CudaMemory : public memory ...@@ -101,7 +103,7 @@ class CudaMemory : public memory
} }
//! Constructor //! Constructor
CudaMemory():is_hm_sync(false),sz(0),dm(0),hm(0),ref_cnt(0) {}; CudaMemory():is_hm_sync(true),sz(0),dm(0),hm(0),ref_cnt(0) {};
//! Destructor //! Destructor
~CudaMemory() ~CudaMemory()
......
...@@ -173,6 +173,8 @@ bool HeapMemory::resize(size_t sz) ...@@ -173,6 +173,8 @@ bool HeapMemory::resize(size_t sz)
//! size plus alignment //! size plus alignment
size_t sz_a = sz+alignement; size_t sz_a = sz+alignement;
this->sz = sz;
//! align it //! align it
align(alignement,1,(void *&)tdm,sz_a); align(alignement,1,(void *&)tdm,sz_a);
...@@ -188,7 +190,7 @@ bool HeapMemory::resize(size_t sz) ...@@ -188,7 +190,7 @@ bool HeapMemory::resize(size_t sz)
dm = tdm; dm = tdm;
dmOrig = tdmOrig; dmOrig = tdmOrig;
this->sz = sz_a; this->sz = sz;
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment