Skip to content

Commit

Permalink
Merge pull request #861 from ROCm/master
Browse files Browse the repository at this point in the history
Sync up with master
  • Loading branch information
jkottiku authored Dec 9, 2024
2 parents 72c5f21 + 4b7ec6f commit 61e5926
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 30 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Full documentation for RVS is available at [ROCmValidationSuite.Readme](https://github.com/ROCm/ROCmValidationSuite).

## RVS 1.1.0 for ROCm 6.3.0

### Added

- Support for hipBLASLT blas library and option to select blas library in conf. file.
- Added Babel, thermal and performance benchmark test for MI308X.

### Changed

- Babel parameters made runtime configurable.

## RVS 1.0.0 for ROCm 6.2.0

### Added
Expand Down
4 changes: 3 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
configuration file, including the ‘all’ value.
-j --json Generate output file in JSON format.
if a path follows this argument, that will be used as json log file;
else a file created in /var/tmp/ with timestamp in name.
-l --debugLogFile Generate log file with output and debug information.
-t --listTests List the test modules present in RVS.
-v --verbose Enable verbose reporting. Equivalent to specifying -d 5 option.
Expand Down
2 changes: 2 additions & 0 deletions docs/ug1main.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ configuration file, including the ‘all’ value.
</td></tr>

<tr><td>-j</td><td>--json</td><td>Generate output file in JSON format.
if a path follows this argument, that will be used as json log file;
else a file created in /var/tmp/ with timestamp in name.
</td></tr>

<tr><td>-l</td><td>--debugLogFile</td><td>Generate log file with output and debug information.
Expand Down
7 changes: 5 additions & 2 deletions include/rvsliblogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <string>
#include <mutex>
#include "include/rvsliblog.h"

bool isPathedFile(const std::string &fname);
bool doesFolderExist(const std::string &fname);

namespace rvs {

Expand All @@ -54,7 +55,7 @@ class logger {
static void quiet() { b_quiet = true; }
//! set logging file
static void set_log_file(const std::string& fname);

static void set_json_log_file(const std::string& fname);
static bool get_ticks(uint32_t* psecs, uint32_t* pusecs);

static int init_log_file();
Expand Down Expand Up @@ -92,6 +93,8 @@ class logger {
static bool tojson_m;
//! 'true' if append to existing log file is requested
static bool append_m;
// state of module specific logs written, only to be run once
static bool initModule;
//! 'true' if the incoming record is the first record in this rvs invocation
static bool isfirstrecord_m;
//! 'true' if the creating record is the first action in rvs invocation
Expand Down
4 changes: 2 additions & 2 deletions pbqt.so/src/action.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
*
* Copyright (c) 2018-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* MIT LICENSE:
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -276,7 +276,7 @@ void pbqt_action::log_json_data(std::string srcnode, std::string dstnode,
default:
break;
}

json_add_kv(json_node, "pass", "true");
json_to_file(json_node, log_level);
}
}
Expand Down
6 changes: 4 additions & 2 deletions pbqt.so/src/action_run.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
*
* Copyright (c) 2018-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* MIT LICENSE:
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -156,7 +156,9 @@ int pbqt_action::run() {
action_result.status = rvs::actionstatus::ACTION_FAILED;
action_result.output = "Parameters not valid. Nothing to execute !!!";
action_callback(&action_result);

if(bjson){
rvs::lp::JsonActionEndNodeCreate();
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion pebb.so/src/action_run.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
*
* Copyright (c) 2018-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* MIT LICENSE:
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down
10 changes: 8 additions & 2 deletions rvs/src/rvsexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ int rvs::exec::run() {
}

// check -j option
if (rvs::options::has_option("-j", &val)) {
std::string s_json_log_file;
if (rvs::options::has_option("-j", &s_json_log_file)) {
logger::to_json(true);
logger::set_json_log_file(s_json_log_file);

}

// check -c option
Expand Down Expand Up @@ -458,9 +461,12 @@ void rvs::exec::do_help() {
cout << " the device values specified for every actions in the\n";
cout << " configuration file, including the ‘all’ value.\n\n";

cout << "-j --json Generate output file in JSON format.\n\n";
cout << "-j --json Generate output file in JSON format.\n";
cout << " if a path follows this argument, that will be used as json log file\n";
cout << " else a file created in /var/tmp/ with timestamp in name.\n\n";

cout << "-l --debugLogFile Generate log file with output and debug information.\n\n";


cout << "-t --listTests List the test modules present in RVS.\n\n";

Expand Down
95 changes: 75 additions & 20 deletions src/rvsliblogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*
*******************************************************************************/
#include "include/rvsliblogger.h"
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>

#include <unistd.h>
#include <time.h>
Expand Down Expand Up @@ -51,6 +54,7 @@ int rvs::logger::loglevel_m(2);
bool rvs::logger::tojson_m(false);
bool rvs::logger::append_m(false);
bool rvs::logger::isfirstrecord_m(true);
bool rvs::logger::initModule(true);
bool rvs::logger::isfirstaction_m(true);
std::mutex rvs::logger::cout_mutex;
std::mutex rvs::logger::log_mutex;
Expand All @@ -71,6 +75,45 @@ const std::string list_start{"["};
const std::string list_end{"]"};
const std::string newline{"\n"};
const std::string json_folder{"/var/tmp/"};

bool isPathedFile(const std::string &fname){
return fname.find('/') != std::string::npos ;
}

bool doesFolderExist(const std::string &fname){
auto loc = fname.find_last_of('/');
auto dirName = fname.substr(0,loc);
DIR* dir = opendir(dirName.c_str());
if (dir == NULL) {
// try creating directory, this doesnt exist. if fails return
int ret = mkdir(dirName.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
if (ret){
return false;
}
}
std::fstream fs;
fs.open(fname, std::ios::out | std::ios::trunc);
if (fs.fail()){// unable to create file in dir
return false;
}
return true;
}

/**
* @brief helper to create json file name
* @return json file name
*/
std::string json_filename(){
std::string json_file;
json_file.assign("rvs");
std::chrono::milliseconds ms = std::chrono::duration_cast< std::chrono::milliseconds >(
std::chrono::system_clock::now().time_since_epoch());
json_file = json_file + "_" + std::to_string(ms.count()) + ".json";
json_file = json_folder + json_file;
return json_file;
}


/**
* @brief Set 'append' flag
*
Expand All @@ -93,6 +136,30 @@ bool rvs::logger::append() {

void rvs::logger::set_log_file(const std::string& fname) {
strncpy(log_file, fname.c_str(), sizeof(log_file));
if (isPathedFile(log_file)){
if (!doesFolderExist(log_file)){
std::cout << "Unable to create log file, check path.";
}
}

}


void rvs::logger::set_json_log_file(const std::string& fname) {
std::stringstream ss;
if (!fname.empty()){
json_log_file = fname;
if (isPathedFile(fname) && !doesFolderExist(fname)){
json_log_file = json_filename();
ss << "Unable to create Json log file specified at" << fname << std::endl;
}

}else{
json_log_file = json_filename();
}
ss << "Json log file created at " << json_log_file << std::endl;
std::lock_guard<std::mutex> lk(cout_mutex);
std::cout << ss.str();
}

/**
Expand Down Expand Up @@ -262,19 +329,6 @@ int rvs::logger::LogExt(const char* Message, const int LogLevel,
return 0;
}

/**
* @brief helper to create json file name
* @return json file name
*/
std::string json_filename(const char* moduleName){
std::string json_file;
json_file.assign(moduleName);
std::chrono::milliseconds ms = std::chrono::duration_cast< std::chrono::milliseconds >(
std::chrono::system_clock::now().time_since_epoch());
json_file = json_file + "_" + std::to_string(ms.count()) + ".json";
json_file = json_folder + json_file;
return json_file;
}

/**
* @brief Create log record
Expand All @@ -295,7 +349,7 @@ void* rvs::logger::LogRecordCreate(const char* Module, const char* Action,
uint32_t sec;
uint32_t usec;
if( json_log_file.empty()){
json_log_file = json_filename(Module);
json_log_file = json_filename();
std::lock_guard<std::mutex> lk(cout_mutex);
std::cout << "json log file is " << json_log_file<< std::endl;
}
Expand Down Expand Up @@ -334,21 +388,20 @@ void* rvs::logger::LogRecordCreate(const char* Module, const char* Action,
#if 1
int rvs::logger::JsonStartNodeCreate(const char* Module, const char* Action) {
if ( json_log_file.empty()){
json_log_file = json_filename(Module);
json_log_file = json_filename();
std::lock_guard<std::mutex> lk(cout_mutex);
std::cout << "json log file is " << json_log_file<< std::endl;
}
std::string row{node_start};
row += std::string("\"") + Module + std::string("\"") + kv_delimit + node_start + newline;
//row += RVSINDENT;
//row += std::string("\"") + Action + std::string("\"") + kv_delimit + list_start + newline;
std::lock_guard<std::mutex> lk(json_log_mutex);
return ToFile(row, true);
}

int rvs::logger::JsonActionStartNodeCreate(const char* Module, const char* Action) {
if(json_log_file.empty()){
if(initModule || json_log_file.empty()){
rvs::logger::JsonStartNodeCreate(Module, Action);
initModule = false;
}
isfirstrecord_m = true;
std::string row{newline};
Expand Down Expand Up @@ -491,10 +544,12 @@ int rvs::logger::ToFile(const std::string& Row, bool json_rec) {
logfile.assign(log_file);
if (logfile == "")
return -1;

// check if folder, and if it exists/can be created.
std::fstream fs;
fs.open(logfile, std::fstream::out | std::fstream::app);

fs.open(logfile, std::fstream::out | std::fstream::app);
if (fs.fail())
return -1;
fs << Row;

fs.close();
Expand Down

0 comments on commit 61e5926

Please sign in to comment.