Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event logging #102

Open
wants to merge 28 commits into
base: event_logging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5a0fcc2
[SHAD #41] added a sample example to test SHAD. Added logging library…
Aug 14, 2018
e41a048
[SHAD #41] Added logging functionalities in both GMT and TBB runtime …
Aug 14, 2018
bc7c767
[SHAD #41] adding compile directory -DSHAD_LOGGING_SYSTEM=/Users/meth…
Aug 14, 2018
4d951f8
[SHAD #41] adding compile directory -DSHAD_LOGGING_SYSTEM=/Users/meth…
Aug 14, 2018
aa69793
[SHAD #41] fixed the cmake issue to link the include folder of log
Aug 14, 2018
ebd07b4
[SHAD #41] Change tbb_tag to gmt_tag for gmt runtime functionalities
Aug 14, 2018
7fde994
[SHAD #41] Fix locality issue
Aug 14, 2018
3ebc626
[SHAD #41] stop shutting down the logger
Aug 15, 2018
761ebd1
[SHAD #41] Remove specific logger from registry when its done
Aug 15, 2018
2f47cfb
[SHAD #41] Remove specific logger from registry when its done
Aug 15, 2018
eea59f8
[SHAD #41] Remove specific logger from registry when its done
Aug 15, 2018
21c9217
[SHAD #41] Remove specific logger from registry when its done
Aug 15, 2018
b5dd120
[SHAD #41] Remove specific logger from registry when its done
Aug 15, 2018
9514e16
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
7daa5e3
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
c353ad5
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
e3b9b9c
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
ef8f28c
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
faa9267
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
eb154af
[SHAD #41] Fix error for duplicate logger
Aug 15, 2018
b5aadec
[SHAD #41] Fix json data loading issue, added functionality to pass s…
Aug 16, 2018
7c3ecdf
[SHAD #41] Updated readme file with instruction of how to install SPD…
Aug 20, 2018
29b387b
[SHAD #41] Rename the python script folder to script
Aug 23, 2018
f319084
[SHAD #41] Controlling the clocking and logging activity based on log…
Aug 23, 2018
5cfb8fe
[SHAD #41] Remove folder pythin_viz
Aug 23, 2018
6ee26e7
[SHAD #41] Adding docString in the script
Aug 24, 2018
690acbb
[SHAD #41] Adding docString in the script
Aug 24, 2018
52ec52c
[SHAD #41] Completed docstring
Sep 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ option(SHAD_ENABLE_CPPLINT "Enable the linting of source code" ON)
option(SHAD_ENABLE_DOXYGEN "Use doxygen to generate the shad API documentation" OFF)
option(SHAD_ENABLE_UNIT_TEST "Enable the compilation of Unit Tests" ON)
option(SHAD_ENABLE_PERFORMANCE_TEST "Enable the compilation of the Performance Tests" OFF)
option(SHAD_ENABLE_LOGGING "Enable the logging system" OFF)

set(
SHAD_RUNTIME_SYSTEM "CPP_SIMPLE" CACHE STRING
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ cmake .. -DCMAKE_INSTALL_PREFIX=$GMT_ROOT \
make -j <SOMETHING_REASONABLE> && make install
```

#### SPDLOG
SHAD uses spdlog which is very fast, header only and C++ library for logging.
It can be installed using the following commands:

```
git clone https://github.com/gabime/spdlog.git
cd spdlog
mkdir build && cd build
cmake ..
make -j <SOMETHING_REASONABLE>
```

### Build SHAD

Before attempting to build SHAD, please take a look at the requirements in [Install Dependencies](#install-dependencies).
Expand All @@ -82,7 +94,9 @@ cmake .. -DCMAKE_INSTALL_PREFIX=$SHADROOT \
-DGMT_ROOT=$GMTROOT \
# endif \
-DGTEST_ROOT=$GTESTROOT \
-DGPERFTOOLS_ROOT=$GPERFTOOLSROOT
-DGPERFTOOLS_ROOT=$GPERFTOOLSROOT \
-DSPDLOG_ROOT=$INCLUDE_DIR_PATH_OF_SPDLOG \
-DSHAD_ENABLE_LOGGING = 1
make -j <SOMETHING_REASONABLE> && make install
```
If you have multiple compilers (or compiler versions) available on your system, you may want to indicate a specific one using the ```-DCMAKE_CXX_COMPILER=<compiler>``` option.
Expand Down
25 changes: 25 additions & 0 deletions cmake/FindSPDLOG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Try to find the SPDLOG header only library
# Created by Methun
# Input variables:
# SPDLOG_ROOT - The SPDLOG root folder directory
# Output variables:
# SPDLOG_FOUND - System has SPDLOG
# SPDLOG_INCLUDE_DIRS - The SPDLOG include directories

include(FindPackageHandleStandardArgs)

if (NOT DEFINED SPDLOG_FOUND)

# Set default search paths
if (SPDLOG_ROOT)
set(SPDLOG_INCLUDE_DIR ${SPDLOG_ROOT}/include CACHE PATH "The include directory for SPDLOG")
endif()

find_path(SPDLOG_INCLUDE_DIRS NAMES spdlog/spdlog.h HINTS ${SPDLOG_INCLUDE_DIR})

find_package_handle_standard_args(SPDLOG
FOUND_VAR SPDLOG_FOUND
REQUIRED_VARS SPDLOG_INCLUDE_DIRS
HANDLE_COMPONENTS)
mark_as_advanced(SPDLOG_INCLUDE_DIR SPDLOG_INCLUDE_DIRS)
endif()
9 changes: 9 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ if (GPERFTOOLS_FOUND)
endif()
endif()

# spdlog: this portion added by methun
if (SHAD_ENABLE_LOGGING)
message(STATUS "Using spdlog library for logging the benchmark.")
find_package(SPDLOG REQUIRED)
message(STATUS ${SPDLOG_INCLUDE_DIRS})
include_directories(${SPDLOG_INCLUDE_DIRS})
set(HAVE_LOGGING 1)
endif()

if (SHAD_ENABLE_UNIT_TEST)
find_package(GTest REQUIRED)
endif()
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_subdirectory(array)
add_subdirectory(edge_index_graph)
add_subdirectory(Number_add)

6 changes: 6 additions & 0 deletions examples/Number_add/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(program add-number)

foreach(p ${program})
add_executable(${p} ${p}.cc)
target_link_libraries(${p} ${SHAD_RUNTIME_LIB} runtime)
endforeach(p)
168 changes: 168 additions & 0 deletions examples/Number_add/add-number.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
//===------------------------------------------------------------*- C++ -*-===//
//
// SHAD
//
// The Scalable High-performance Algorithms and Data Structure Library
//
//===----------------------------------------------------------------------===//
//
// Copyright 2018 Battelle Memorial Institute
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
//
//===----------------------------------------------------------------------===//

/*
Developer Date Description
================================================================================
Methun K 07/11/2018 Simple implementation of adding huge amount of numbers to compare the runtime among traditional forloop, shad sync ForEach and AsyncForEach method.
Methun K 07/26/2018 Replace the console print to log write for testing
--------------------------------------------------------------------------------
*/

#include <atomic>
#include <random>

#include "shad/data_structures/array.h"
#include "shad/runtime/runtime.h"
#include "shad/util/measure.h"
#include "shad/util/slog.h"

// Local sum container
std::atomic<size_t> bigSum(0);
std::atomic<size_t> offset(0);

void getRand(size_t index, int& rVal, size_t& range){
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(0,range);

rVal = (offset++) + distribution(generator);

offset = offset % 999999;
}

void getAsyncRand(shad::rt::Handle& handle, size_t index, int& rVal, size_t& range){
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(0,2*range);

rVal = (offset++) + distribution(generator);

offset = offset % 999989;
}

void accumulateForEach(size_t pos, int& val){
bigSum += val;
}

void accumulateAsyncForEach(shad::rt::Handle& handle, size_t pos, int& val){
bigSum += val;
}

template<typename T>
void printArray(T &array, const size_t &size){
for(size_t i=0;i<size;i++){
std::cout<<array->At(i)<<",";
}
std::cout<<"\n";
}

void syncLoadFor(const size_t& arraySize){
int a(0);
auto myarray = shad::Array<int>::Create(arraySize,a);

std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(0,99999);

#if defined HAVE_LOGGING
auto t1 = shad_clock::now();
#endif

for(size_t i=0; i<arraySize;i++){
int rVal = distribution(generator);
myarray->InsertAt(i, rVal);
}

#if defined HAVE_LOGGING
auto t2 = shad_clock::now();
std::chrono::duration<double> diff = t2-t1;
auto log_handler = shad::slog::ShadLog::Instance();
log_handler->printlf("For:Load", diff.count(), nullptr, shad::rt::thisLocality(), shad::rt::thisLocality(), sizeof(size_t), sizeof(std::atomic<size_t>), arraySize);

t1 = shad_clock::now();
#endif

bigSum = 0;
for(size_t i=0; i<arraySize;i++){
bigSum += myarray->At(i);
}

#if defined HAVE_LOGGING
t2 = shad_clock::now();
diff = t2-t1;
log_handler->printlf("For:Sum", diff.count(), nullptr, shad::rt::thisLocality(), shad::rt::thisLocality(), sizeof(size_t), sizeof(std::atomic<size_t>), arraySize);
#endif

std::cout<<"Sum: "<<bigSum<<std::endl;
}

void syncLoadForEach(const size_t& arraySize){
int a(0);
auto myarray = shad::Array<int>::Create(arraySize,a);
size_t r = 919199;

myarray->ForEach(getRand, r);

bigSum = 0;
myarray->ForEach(accumulateForEach);

std::cout<<"Sum: "<<bigSum<<std::endl;
}

void asyncLoadForEach(const size_t& arraySize){
int a(0);
auto myarray = shad::Array<int>::Create(arraySize,a);
size_t r = 898989;
shad::rt::Handle handle;

myarray->AsyncForEach(handle, getAsyncRand, r);
shad::rt::waitForCompletion(handle);

//printArray(myarray, arraySize);

bigSum = 0;
myarray->AsyncForEach(handle, accumulateAsyncForEach);
shad::rt::waitForCompletion(handle);

std::cout<<"Sum: "<<bigSum<<std::endl;
}

void sumNumbers(size_t arraySize){
std::cout<<"Array Size:"<<arraySize<<std::endl;

syncLoadFor(arraySize);
syncLoadForEach(arraySize);
asyncLoadForEach(arraySize);
}

namespace shad {
int main(int argc, char**argv) {
std::cout<<"Running...\n";
size_t arraySize = 0;
if(argc<2) arraySize = 9999999;
else arraySize = std::stol(argv[1]);
std::cout<<argc<<", "<<argv[1]<<std::endl;
sumNumbers(arraySize);

return 0;
}
}
1 change: 1 addition & 0 deletions include/shad/config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ constexpr auto kShadPlatform = "@PLATFORM@";
#cmakedefine HAVE_CPP_SIMPLE
#cmakedefine HAVE_GMT
#cmakedefine HAVE_TBB
#cmakedefine HAVE_LOGGING // spdlog: This include added by methun

#endif // INCLUDE_SHAD_CONFIG_H_
Loading