Commit 70ba6f69 authored by Martin Perdacher's avatar Martin Perdacher

removed papi

parent 53632047
cmake_minimum_required(VERSION 3.6)
project(blasJoin)
set(UTIL_SOURCES util/dataIo.cpp util/arguments.cpp util/allocation.cpp measure/energy.cpp measure/papicalls.cpp measure/timer.cpp)
set(UTIL_SOURCES util/dataIo.cpp util/arguments.cpp util/allocation.cpp measure/energy.cpp measure/timer.cpp)
set(SOURCE_FILES main.cpp blasJoin/blasJoin.cpp ${UTIL_SOURCES})
#####################
# build type: Release
#####################
# NDDEBUG turns off asserts
set(CMAKE_CXX_FLAGS "-std=c++11 ")
set(CMAKE_CXX_FLAGS "-std=c++11")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=knl -mtune=knl -fpic -ffast-math -DNDEBUG -O3 -DNDDEBUG -fopenmp -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5 -lboost_system")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xmic-avx512 -qopenmp -DNDEBUG -O3 -lmkl_intel_thread -liomp5 -lpthread -lmkl_core -lmkl_intel_lp64 -lboost_system")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopt-report=2")
# xeon phi (knl) specific:
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lmemkind")
add_definitions(-DDEBUG)
endif()
......
#include "blasJoin.h"
void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, CounterBin * hwcounters){
void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts){
assert( BLOCKSIZE < N && BLOCKSIZE < 21000 && BLOCKSIZE > 1);
double elapsed=0.0;
// CUtilTimer timer;
PapiBin papi_bin;
double *iresult = NULL;
*joinCounts = 0;
......@@ -21,7 +20,6 @@ void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const do
iresult = (double*) ddr_alloc(BLOCKSIZE * BLOCKSIZE * sizeof(double));
// timer.start();
papi_bin.start();
const double EPS_SQUARED = (EPS * EPS) / 4.0 ;
......@@ -29,7 +27,7 @@ void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const do
#pragma omp for
for ( int i = 0 ; i < N ; i++ ){
p[i] = EPS_SQUARED - cblas_ddot(D, &x[i*D], 1, &x[i*D], 1) / 2.0;
}
}
omp_set_num_threads(THREADS);
mkl_set_num_threads(THREADS);
......@@ -96,22 +94,18 @@ void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const do
}
// timer.stop();
papi_bin.stop();
*hwcounters = papi_bin.getBin();
ddr_free(iresult);
ddr_free(p);
}
/* returns energy consumption [watthours] */
void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, CounterBin * hwcounters, boost::lockfree::queue<join_pair> &queue){
void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, boost::lockfree::queue<join_pair> &queue){
assert( BLOCKSIZE < N && BLOCKSIZE < 21000 && BLOCKSIZE > 1);
double elapsed=0.0;
// CUtilTimer timer;
PapiBin papi_bin;
double *iresult = NULL;
*joinCounts = 0;
......@@ -125,7 +119,6 @@ void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const
iresult = (double*) ddr_alloc(BLOCKSIZE * BLOCKSIZE * sizeof(double));
// timer.start();
papi_bin.start();
const double EPS_SQUARED = (EPS * EPS) / 4.0 ;
......@@ -239,8 +232,6 @@ void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const
}
// timer.stop();
papi_bin.stop();
*hwcounters = papi_bin.getBin();
ddr_free(iresult);
ddr_free(p);
......
......@@ -13,7 +13,6 @@
#include "../util/allocation.h"
// #include "../util/timer.h"
#include "../measure/energy.h"
#include "../measure/papicalls.h"
#include "../util/dataIo.h"
#include <boost/lockfree/queue.hpp>
......@@ -24,8 +23,8 @@ struct join_pair {
size_t p2;
};
void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, CounterBin * hwcounters);
void blasJoinCountOnly(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts);
void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, CounterBin * hwcounters, boost::lockfree::queue<join_pair> &que);
void blasJoinStoreResults(const double *x, const size_t N, const size_t D, const double EPS, const unsigned int THREADS, const size_t BLOCKSIZE, size_t *joinCounts, boost::lockfree::queue<join_pair> &que);
#endif
......@@ -28,7 +28,6 @@ int consumer(boost::lockfree::queue<join_pair> &queue)
#endif
int main(int argc, char** argv) {
CounterBin hwcounters;
char filename[255] = "";
double watthours=0.0;
bool isBinary = false;
......@@ -65,9 +64,9 @@ int main(int argc, char** argv) {
}
#ifdef COUNT_ONLY
blasJoinCountOnly( x, N, D, EPS, threads, blocksize, &joinCounts, &hwcounters);
blasJoinCountOnly( x, N, D, EPS, threads, blocksize, &joinCounts);
#else
blasJoinStoreResults( x, N, D, EPS, threads, blocksize, &joinCounts, &hwcounters, queue);
blasJoinStoreResults( x, N, D, EPS, threads, blocksize, &joinCounts, queue);
#endif
#ifndef COUNT_ONLY
......@@ -82,7 +81,7 @@ int main(int argc, char** argv) {
#pragma omp parallel
{
if ( omp_get_thread_num() == 0 ){
printf("%ld;%ld;%2.12f;%ld;%d;%f;%lu;%f\n", N, D, EPS, blocksize, omp_get_num_threads(), hwcounters.rtime, joinCounts, hwcounters.whours);
printf("%ld;%ld;%2.12f;%ld;%d;%lu\n", N, D, EPS, blocksize, omp_get_num_threads(), joinCounts);
}
}
......
#include "papicalls.h"
PapiBin::PapiBin(){
// int num_hwcntrs;
// if ((num_hwcntrs = PAPI_num_counters()) < 0 ){
// if ((num_hwcntrs = PAPI_num_counters()) < NUM_EVENTS ){
// fprintf(stderr,"Info:: This installation does not support PAPI: %s\n", PAPI_strerror(num_hwcntrs));
// exit(1);
// }
// }
//
// if ((num_hwcntrs = PAPI_num_counters()) < NUM_EVENTS ){
// fprintf(stderr,"Info:: This machine does not provide sufficient hardware counters.\n");
// exit(1);
// }
}
void PapiBin::start(){
int retval=0;
// counters.l1 = 0; // counters.l2 = 0; counters.l3 = 0;
// counters.rtime = 0.0; counters.ptime = 0.0; counters.flops = 0; counters.mflops;
// if ( ( retval = PAPI_flops( &counters.rtime, &counters.ptime, &counters.flops, &counters.mflops ) ) < PAPI_OK ){
// fprintf(stderr,"Call to PAPI_flops failed: %s\n", PAPI_strerror(retval));
// exit(1);
// }
energy_consume.reset(); energy_consume.start();
timer.start();
// if ((retval = PAPI_start_counters(events, NUM_EVENTS)) < PAPI_OK) {
// fprintf(stderr, "PAPI failed to start counters: %s\n", PAPI_strerror(retval));
// exit(1);
// }
}
void PapiBin::stop(){
// int retval=0;
// long_long values[NUM_EVENTS];
//
// if ((retval = PAPI_stop_counters(values, NUM_EVENTS)) < PAPI_OK) {
// fprintf(stderr, "PAPI failed to start counters: %s\n", PAPI_strerror(retval));
// exit(1);
// }
// if ( ( retval = PAPI_flops( &counters.rtime, &counters.ptime, &counters.flops, &counters.mflops ) ) < PAPI_OK ){
// fprintf(stderr,"Call to PAPI_flops failed: %s\n", PAPI_strerror(retval));
// exit(1);
// }
timer.stop();
energy_consume.stop();
counters.rtime = timer.get_time();
counters.whours = energy_consume.getWH();
}
CounterBin PapiBin::getBin(){
return counters;
}
#ifndef CACHE_HIERACHY_H
#define CACHE_HIERACHY_H
#include <papi.h>
#include <stdio.h>
#include <stdlib.h>
#include "timer.h"
#include "energy.h"
#define NUM_EVENTS 1
struct CounterBin{
double whours;
double rtime;
};
class PapiBin{
public:
PapiBin();
void start();
void stop();
CounterBin getBin();
private:
CUtilTimer timer;
Hioki energy_consume;
// const int NUM_EVENTS=3;
// int events[NUM_EVENTS] = { PAPI_L1_DCM , PAPI_L2_DCM, PAPI_L3_DCM };
// int events[NUM_EVENTS] = { PAPI_L1_DCM };
CounterBin counters;
};
#endif
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