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

Prepare release version #33

Merged
merged 8 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"description": "toolkitICL",
"license": "other-open",
"title": "IANW-Projects/toolkitICL",
"version": "vX.Y.Z",
"version": "v1.0.0",
"upload_type": "software",
"publication_date": "2019-02-XY",
"publication_date": "2019-03-18",
"creators": [
{
"affiliation": "TU Braunschweig",
"affiliation": "IANW",
"name": "Philip Heinisch"
},
{
"affiliation": "TU Braunschweig",
"name": "Hendrik Ranocha"
"affiliation": "IANW",
"name": "Katharina Ostaszewski"
},
{
"affiliation": "TU Braunschweig",
"name": "Katharina Ostaszewski"
"affiliation": "IANW",
"name": "Hendrik Ranocha"
}
],
"access_right": "open"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ During execution, power and temperture loggin is only available, if the `EnergyL
Depending on the architecture, the power consumption is determined by the system based on a heuristic algorithm and not measured directly.
The necessary drivers and additional information are available at [Intel]( https://software.intel.com/en-us/articles/intel-power-gadget-20).

The default path will be used to search for the necessary libraries (HDF5, Intel Power Gadget, AMD µProf, CUDA). It is also possible to place the libraries together with the executable in the same folder.

## Usage

Examples on how to create the input HDF5 files are provided in the directory
Expand Down
6 changes: 1 addition & 5 deletions include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@


// file system functions
inline bool fileExists(char const* filename)
{
return access(filename, 0) == 0;
}

inline bool fileExists(std::string const& filename)
{
return fileExists(filename.c_str());
return access(filename.c_str(), 0) == 0;
}


Expand Down
12 changes: 12 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ add_executable(toolkitICL ${SOURCES} $<TARGET_OBJECTS:hdf5_io>)

set(LIBRARIES "${OpenCL_LIBRARIES};${HDF5_HL_LIBRARIES};${HDF5_LIBRARIES}")

#set(MSVC_LINK_FLAGS "/DELAYLOAD:")

# link libraries
IF(USENVML)
if(MSVC)
list(APPEND LIBRARIES "nvml.lib")
set(MSVC_LINK_FLAGS "${MSVC_LINK_FLAGS}/DELAYLOAD:nvml.dll ")
ELSE()
list(APPEND LIBRARIES "libnvidia-ml.so")
ENDIF()
Expand All @@ -71,11 +74,20 @@ ENDIF(USENVML)
IF(USEAMDP)
if(MSVC)
list(APPEND LIBRARIES "AMDPowerProfileAPI.lib")
set(MSVC_LINK_FLAGS "${MSVC_LINK_FLAGS}/DELAYLOAD:AMDPowerProfileAPI.dll ")
ELSE()
list(APPEND LIBRARIES "libAMDPowerProfileAPI.so")
ENDIF()
ENDIF(USEAMDP)

MESSAGE(STATUS "Used libs: ${LIBRARIES}")

if(MSVC)
MESSAGE(STATUS "Used linker flags: ${MSVC_LINK_FLAGS}")
set_target_properties(toolkitICL PROPERTIES LINK_FLAGS "${MSVC_LINK_FLAGS}")
ENDIF()


TARGET_LINK_LIBRARIES(toolkitICL ${LIBRARIES})


83 changes: 59 additions & 24 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "ocl_dev_mgr.hpp"
#include "timer.hpp"


#if defined(_WIN32)
#pragma once
#include <windows.h>
#include <sys/timeb.h>
#include "shlobj.h"

int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
Expand Down Expand Up @@ -333,14 +333,11 @@ void intel_log_temp_func()
if (rapl->detect_socket1() == true)
{
temp1 = rapl->get_temp1();
intel_temp1.push_back(temp1);
ranocha marked this conversation as resolved.
Show resolved Hide resolved
}

intel_temp_time.push_back(timeval2storage(rawtime));
intel_temp0.push_back(temp0);
if (rapl->detect_socket1() == true)
{
intel_temp1.push_back(temp1);
}
}
}
}
Expand Down Expand Up @@ -451,9 +448,6 @@ void nvidia_log_power_func()
nvidia_power.clear();
nvidia_power_time.clear();

result = nvmlInit();
if (NVML_SUCCESS == result)
{
nvmlDevice_t device;
nvmlDeviceGetHandleByIndex(0, &device);

Expand All @@ -469,7 +463,6 @@ void nvidia_log_power_func()
}

nvmlShutdown();
}
}
}

Expand All @@ -484,9 +477,6 @@ void nvidia_log_temp_func()
nvidia_temp.clear();
nvidia_temp_time.clear();

result = nvmlInit();
if (NVML_SUCCESS == result)
{
nvmlDevice_t device;
nvmlDeviceGetHandleByIndex(0, &device);

Expand All @@ -500,7 +490,7 @@ void nvidia_log_temp_func()
}

nvmlShutdown();
}

}
}

Expand Down Expand Up @@ -652,6 +642,11 @@ int main(int argc, char *argv[]) {

cl_uint deviceIndex = 0; // set default OpenCL Device

ocl_dev_mgr& dev_mgr = ocl_dev_mgr::getInstance();
cl_uint devices_availble = dev_mgr.get_avail_dev_num();

cout << "Available OpenCL devices: " << devices_availble << endl;

// parse command line arguments
bool benchmark_mode = false;
if (cmdOptionExists(argv, argv + argc, "-b")) {
Expand Down Expand Up @@ -712,11 +707,8 @@ int main(int argc, char *argv[]) {
}

#endif
ocl_dev_mgr& dev_mgr = ocl_dev_mgr::getInstance();
cl_uint devices_availble = dev_mgr.get_avail_dev_num();

cout << "Available devices: " << devices_availble << endl
<< dev_mgr.get_avail_dev_info(deviceIndex).name.c_str() << endl;
cout << dev_mgr.get_avail_dev_info(deviceIndex).name.c_str() << endl;
cout << "OpenCL version: " << dev_mgr.get_avail_dev_info(deviceIndex).ocl_version.c_str() << endl;
cout << "Memory limit: " << dev_mgr.get_avail_dev_info(deviceIndex).max_mem << endl;
cout << "WG limit: " << dev_mgr.get_avail_dev_info(deviceIndex).wg_size << endl << endl;
Expand Down Expand Up @@ -942,11 +934,47 @@ int main(int argc, char *argv[]) {
#endif

#if defined(USENVML)
#if defined(_WIN32)
if (nvidia_log_power || nvidia_log_temp)
{
cout << "Using NVML interface..." << endl;
h5_create_dir(out_name, "/housekeeping");
h5_create_dir(out_name, "/housekeeping/nvidia");
//Get Program Files path from system
TCHAR pf[MAX_PATH];
ranocha marked this conversation as resolved.
Show resolved Hide resolved
SHGetSpecialFolderPath(0,pf,CSIDL_PROGRAM_FILES,FALSE);
std::string nvsmi_path;
nvsmi_path.append(pf);
nvsmi_path.append("/NVIDIA Corporation/NVSMI/nvml.dll");
if (fileExists(nvsmi_path)) {
LoadLibraryEx(nvsmi_path.c_str(), NULL, 0);
}else {
if (fileExists("nvml.dll")) {
LoadLibraryEx("nvml.dll", NULL, 0);
}
else {
//No NVML found abort
cout << "NVML library not found..." << endl;
nvidia_log_temp = false;
nvidia_log_power = false;
nvidia_power_rate = 0;
nvidia_temp_rate = 0;
}
}
}
#endif
if (nvidia_log_power || nvidia_log_temp)
{
nvmlReturn_t result;
result = nvmlInit();
if (NVML_SUCCESS == result)
{
cout << "Using NVML interface..." << endl;
h5_create_dir(out_name, "/housekeeping");
h5_create_dir(out_name, "/housekeeping/nvidia");
}
else {
cout << "NVML failure..." << endl;
nvidia_log_temp = false;
nvidia_log_power = false;
}
}
std::thread nvidia_log_power_thread(nvidia_log_power_func);
std::thread nvidia_log_temp_thread(nvidia_log_temp_func);
Expand All @@ -957,13 +985,12 @@ int main(int argc, char *argv[]) {
{
cout << "Using Intel Power Gadget interface..." << endl;
h5_create_dir(out_name, "/housekeeping");
h5_create_dir(out_name, "/housekeeping/intel");
h5_create_dir(out_name, "/housekeeping/intel");
rapl = new Rapl();
}

if (intel_log_power)
{

rapl = new Rapl();
h5_write_single<float>(out_name, "/housekeeping/intel/TDP" , (float)rapl->get_TDP(),
"Thermal Design Power in watt");

Expand Down Expand Up @@ -1084,7 +1111,10 @@ int main(int argc, char *argv[]) {
amd_log_power_thread.join();
//amd_log_temp_thread.join();

AMDTPwrStopProfiling();
if ((amd_power_rate > 0) || (amd_temp_rate > 0)) {

AMDTPwrStopProfiling();
}

if (amd_power_rate > 0)
{
Expand Down Expand Up @@ -1219,6 +1249,11 @@ int main(int argc, char *argv[]) {
nvidia_log_power_thread.join();
nvidia_log_temp_thread.join();

if ((nvidia_power_rate > 0)||(nvidia_temp_rate > 0))
{
nvmlShutdown();
}

if (nvidia_power_rate > 0) {

h5_write_buffer<float>(out_name, "/housekeeping/nvidia/power", nvidia_power.data(), nvidia_power.size(),
Expand Down
2 changes: 1 addition & 1 deletion src/rapl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Rapl::Rapl(){
pGetNumNodes(&numCPUnodes);
if (numCPUnodes > 1)
{
pp1_supported = true;
socket1_detected = true;
ranocha marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down