from waflib import Logs def configure(ctx): ctx.load(ctx.options.cpp) if ctx.options.flags: ctx.env.append_unique("CXXFLAGS", ctx.options.flags.split( )) ctx.env.append_unique("CXXFLAGS", [ "-std=c++11", "-fPIC"]) #no openMP if ctx.options.withgcc: if not ctx.options.noopenmp: ctx.env.append_unique("CXXFLAGS", [ "-fopenmp" ]) #GCC ctx.env.append_unique("DEFINES", [ "HAVE_OMP_H=1" ]) #with openMP else: ctx.env.append_unique("NOOPENMP", "NOOPENMP" ) else: if not ctx.options.noopenmp: ctx.env.append_unique("CXXFLAGS", [ "-qopenmp" ]) #Intel ctx.env.append_unique("DEFINES", [ "HAVE_OMP_H=1" ]) #with openMP else: ctx.env.append_unique("NOOPENMP", "NOOPENMP" ) ctx.env.append_unique("DEFINES", [ "MERIC_PATH=\""+ctx.path.abspath()+"\""]) if ctx.options.debug: ctx.env.append_unique("DEFINES", [ "__MERIC_DEBUG__" ]) if ctx.options.verbose: ctx.env.append_unique("DEFINES", [ "VERBOSE" ]) if (not ctx.check_cc(header_name="hdeem.h", execute=False, mandatory=False)): ctx.env.append_unique("CXXFLAGS", [ "-I"+ctx.path.abspath()+"/include/"]) ctx.check_cc(header_name="linux/perf_event.h", execute=False, mandatory=False) if((not ctx.check_cc(header_name="x86_adapt.h", execute=False, mandatory=False)) and (not ctx.check_cc(header_name="msr_core.h", execute=False, mandatory=False))): ctx.check_cc(header_name="numa.h", execute=False, mandatory=True) ctx.check_cc(header_name="cpufreq.h", execute=False, mandatory=False) ctx.check_cc(header_name="papi.h", execute=False, mandatory=False) ctx.check_cc(header_name="hdf5.h", execute=False, mandatory=False) ctx.check_cc(header_name="restclient-cpp/restclient.h", execute=False, mandatory=False) # ctx.check_cc(header_name="cilk/cilk_api.h", execute=False, mandatory=False) # ctx.env.append_unique("DEFINES", [ "HAVE_LINUX_PERF_EVENT_H" ]) #if problem with searching # ctx.env.append_unique("DEFINES", [ "HAVE_X86_ADAPT_H" ]) #if problem with searching if ctx.options.noopenmp: ctx.find_program(ctx.options.mpi, var="MPICXX", mandatory=True) else: ctx.find_program(ctx.options.mpi, var="MPICXX", mandatory=False) if ctx.env.MPICXX: ctx.setenv("mpi", ctx.env.derive()) ctx.env.CXX = list(ctx.env.MPICXX) ctx.env.LINK_CXX = ctx.env.CXX ctx.env.append_unique("DEFINES", [ "HAVE_MPI_H=1" ]) ctx.msg("Compiler flags", " ".join(ctx.env["CXXFLAGS"])) # print(ctx.env) if not ctx.env.MPICXX: Logs.warn("MPI compiler not found. Only shared memory parallelization is supported") def build(ctx): ctx.objects( source = ctx.path.ant_glob('src/basis/*.cpp') + ctx.path.ant_glob('src/store/*.cpp') + ctx.path.ant_glob('src/meric/*.cpp') + ctx.path.ant_glob('src/wrapper/*.cpp'), target = "basis", ) if not ctx.env.NOOPENMP: #MERIC ctx.stlib( source = ctx.path.ant_glob('src/meric/shared/*.cpp'), target = "meric", use = "basis", install_path = "lib" ) ctx.shlib( source = ctx.path.ant_glob('src/meric/shared/*.cpp'), target = "meric", use = "basis", install_path = "lib" ) #TIMEPROF ctx.stlib( source = ctx.path.ant_glob('src/timeprof/*.cpp'), target = "timeprof", use = "basis", install_path = "lib" ) ctx.shlib( source = ctx.path.ant_glob('src/timeprof/*.cpp'), target = "timeprof", use = "basis", install_path = "lib" ) suffix="" else: suffix="only" #MERIC MPI if not ctx.env.MPICXX: return ctx.all_envs["mpi"].LINK_CXX = ctx.all_envs["mpi"].CXX ctx.stlib( source = ctx.path.ant_glob('src/meric/distributed/*.cpp'), target = "mericmpi"+suffix, use = "basis", install_path = "lib", env = ctx.all_envs["mpi"] ) ctx.shlib( source = ctx.path.ant_glob('src/meric/distributed/*.cpp'), target = "mericmpi"+suffix, use = "basis", install_path = "lib", env = ctx.all_envs["mpi"] ) #TIMEPROF MPI ctx.stlib( source = ctx.path.ant_glob('src/timeprof/*.cpp'), target = "timeprofmpi"+suffix, use = "basis", install_path = "lib", env = ctx.all_envs["mpi"] ) ctx.shlib( source = ctx.path.ant_glob('src/timeprof/*.cpp'), target = "timeprofmpi"+suffix, use = "basis", install_path = "lib", env = ctx.all_envs["mpi"] ) def options(opt): opt.add_option( "--withgcc", action="store_true", default=False, help="use GCC instead of Intel compiler" ) opt.add_option( "--verbose", action="store_true", default=False, help="verbose" ) opt.add_option( "--dummy", action="store_true", default=False, help="use dummy HDEEM wrapper" ) opt.add_option( "--debug", action="store_true", default=False, help="active debug output" ) opt.add_option( "--cpp", action="store", default="g++", help="C++ compiler" ) opt.add_option( "--mpi", action="store", default="mpic++", help="MPI C++ compiler" ) opt.add_option( "--noopenmp", action="store", default=False, help="Compilation of MPI version without OpenMP" ) opt.add_option( "--flags", action="store", default="-O2", help="Compiler flags (-std=c++11, -fPIC and -qopenmp/-fopenmp are default)" )