Commit 6de64ff4 authored by martinp16cs's avatar martinp16cs

added main and cmake

parent 42c3d394
cmake_minimum_required(VERSION 3.6)
project(blasJoin)
set(UTIL_SOURCES util/timer.cpp util/dataIo.cpp util/arguments.cpp util/allocation.cpp)
set(SOURCE_FILES main.cpp blasJoin/blasJoin.cpp ${UTIL_SOURCES})
#####################
# build type: Release
#####################
# NDDEBUG turns off asserts
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=knl -mtune=knl -fpic -ffast-math -O3 -DNDDEBUG -fopenmp -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp -axCOMMON-AVX512 -O3 -liomp5 -lpthread -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread")
# xeon phi (knl) specific:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lmemkind")
endif()
add_definitions(-DNUM_THREADS=64)
####################
# build type: Debug
####################
# cmake -D CMAKE_BUILD_TYPE:STRING=Debug ..
# and ignore the warning: "Manually-specified variables were not used by the project: CMAKE_BUID_TYPE"
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -march=knl -mtune=knl -fpic -ffast-math -O0 -fopenmp")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -fpic -qopenmp -axCOMMON-AVX512 -lmemkind -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lpthread -g -debug all -save-temps -Wl,-no_pie -O0")
endif()
# adding MKL include directory
include_directories($ENV{MKLROOT}/include)
# xeon-phi
link_directories($ENV{MKLROOT}/lib/intel64)
# libraries
find_library ( mkl_lp64_LIB NAMES libmkl_intel_lp64.a
PATHS $ENV{MKLROOT} PATH_SUFFIXES lib)
find_library ( mkl_core_LIB NAMES libmkl_core.a
PATHS $ENV{MKLROOT} PATH_SUFFIXES lib)
find_library ( mkl_thread_LIB NAMES libmkl_intel_thread.a
PATHS $ENV{MKLROOT} PATH_SUFFIXES lib)
find_library ( mkl_omp_LIB NAMES libiomp5.a
PATHS $ENV{MKLROOT} PATH_SUFFIXES lib)
add_executable(blasJoin ${SOURCE_FILES})
#include <stdio.h>
#include <omp.h>
#include "util/allocation.h"
#include "util/arguments.h"
#include "util/dataIo.h"
#include "blasJoin/blasJoin.h"
int main(int argc, char** argv) {
double *x = NULL;
CUtilTimer timer;
char filename[] = "";
double elapsed=0.0;
bool isBinary = false;
size_t threads = 64;
size_t N=200, D=20;
double EPS=0.2;
parsing_args(argc,argv, &N, &EPS, &D, &threads, filename, isBinary);
N = N * 1000;
if ( threads != 0 ){
omp_set_num_threads(threads);
}
x = (double*) ddr_alloc(sizeof (double)*N * D);
if ( strcmp(filename,"" ) == 0) {
random_init(x,N,D);
}else{
read_file(x, N, D, filename, isBinary);
}
elapsed = blasJoin( x, N, D, EPS, threads);
printf("%d; %d; %f; %f\n", N,D,EPS,elapsed);
ddr_free(x);
return 0;
}
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