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)
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])])
AC_CONFIG_HEADER([src/config/config.h])
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([AX_BOOST],,[m4_include([m4/ax_boost.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 "
CXXFLAGS+=" --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter "
NVCCFLAGS=" "
INCLUDES_PATH=" -Iconfig "
# Checks for programs.
AC_PROG_CXX
......@@ -31,9 +25,25 @@ AC_PROG_CXX
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
......@@ -56,55 +66,52 @@ if test x"$debuger" = x"yes"; then
CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 "
NVCCFLAGS+="$NVCCFLAGS -g -O0 "
else
CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 "
CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 -funroll-loops "
NVCCFLAGS+="$NVCCFLAGS -O3 "
fi
##### CHECK FOR BOOST ##############
AX_BOOST([1.52],[],[])
####### 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"
)
if test x"$NVCC_EXIST" = x"yes"; then
AC_MSG_CHECKING(whether to build with GPU support)
gpu_support=yes
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([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")
###########################
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"],[])
AX_BOOST([1.52],[],[])
##########################
AC_SUBST(NVCCFLAGS)
AC_SUBST(INCLUDES_PATH)
# Checks for typedefs, structures, and compiler characteristics.
......@@ -115,59 +122,26 @@ 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 *"
if [ test x"$profiler" = x"yes" ]; then
echo "* profiler: yes *"
else
echo "* sse: no *"
echo "* profiler: no *"
fi
if [ test x"$no_mmx" = x"no" ]; then
echo "* mmx: yes *"
if [ test x"$memcheck" = x"yes" ]; then
echo "* memcheck: yes *"
else
echo "* mmx: no *"
echo "* memcheck: no *"
fi
if [ test x"$profiler" = x"yes" ]; then
echo "* profiler: yes *"
if [ test x"$test_cov" = x"yes" ]; then
echo "* test coverage: yes *"
else
echo "* profiler: no *"
echo "* test coverage: 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
......
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
bin_PROGRAMS = ppline
ppline_SOURCES = main.cpp Memleak_check.cpp
ppline_CXXFLAGS = $(CUDA_CFLAGS)
ppline_CFLAGS = $(CUDA_CFLAGS)
ppline_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/
bin_PROGRAMS = mem
mem_SOURCES = main.cpp memory/HeapMemory.cpp memory/CudaMemory.cu
mem_CXXFLAGS = $(INCLUDES_PATH)
mem_CFLAGS =
mem_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/
.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 @@
#include "CudaMemory.cuh"
#include "cuda_macro.h"
#include <cstring>
#include "Memleak_check.hpp"
/*! \brief Allocate a chunk of memory
*
......@@ -35,6 +34,7 @@ void CudaMemory::destroy()
{
//! Release the allocated memory
CUDA_SAFE_CALL(cudaFree(dm));
dm = NULL;
}
if (hm != NULL)
......@@ -45,6 +45,7 @@ void CudaMemory::destroy()
//! remove hm
check_delete(hm);
#endif
hm = NULL;
}
}
......@@ -177,23 +178,41 @@ bool CudaMemory::resize(size_t sz)
if (size() == 0)
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
void * tdm;
if (this->sz < sz)
CUDA_SAFE_CALL(cudaMalloc(&tdm,sz));
if (dm != NULL)
{
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
destroy();
dm = tdm;
hm = thm;
//! change to the new buffer
dm = tdm;
this->sz = sz;
return true;
......@@ -207,21 +226,18 @@ bool CudaMemory::resize(size_t sz)
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 (is_hm_sync)
return hm;
//! we have to synchronize
//| allocate an host mempory
if (hm == NULL)
allocate_host(sz);
//! copy from device to host memory
CUDA_SAFE_CALL(cudaMemcpy(dm,hm,sz,cudaMemcpyDeviceToHost));
CUDA_SAFE_CALL(cudaMemcpy(hm,dm,sz,cudaMemcpyDeviceToHost));
return hm;
}
......@@ -50,6 +50,8 @@ class CudaMemory : public memory
//! Allocate an host buffer
void allocate_host(size_t sz);
public:
//! allocate memory
virtual bool allocate(size_t sz);
//! destroy memory
......@@ -101,7 +103,7 @@ class CudaMemory : public memory
}
//! 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
~CudaMemory()
......
......@@ -173,6 +173,8 @@ bool HeapMemory::resize(size_t sz)
//! size plus alignment
size_t sz_a = sz+alignement;
this->sz = sz;
//! align it
align(alignement,1,(void *&)tdm,sz_a);
......@@ -188,7 +190,7 @@ bool HeapMemory::resize(size_t sz)
dm = tdm;
dmOrig = tdmOrig;
this->sz = sz_a;
this->sz = sz;
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