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

Backend level argument for iprof #93

Merged
merged 59 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
beb118e
draft with bad practice in configure.ac
DonAurelio Apr 27, 2023
7d57ad1
fix
DonAurelio Apr 28, 2023
f38562e
fix
DonAurelio Apr 28, 2023
9b4b701
fix tally test
DonAurelio Apr 28, 2023
0296987
Fix narrowing conversion error
DonAurelio Apr 28, 2023
d19c9a2
Fix distcheck
DonAurelio Apr 28, 2023
bce81ee
enable compact
DonAurelio Apr 28, 2023
3cb0601
testing g++-7
DonAurelio Apr 28, 2023
218df9b
checking g++ version
DonAurelio Apr 28, 2023
9f5c260
cleaning
DonAurelio May 1, 2023
dc1ddb9
Add removed g++ library
DonAurelio May 1, 2023
cf78bec
add btx_tally pluging and component
DonAurelio May 1, 2023
4fc5a1d
suggestions
DonAurelio May 1, 2023
e62153a
suggestions
DonAurelio May 2, 2023
f55386e
suggestions
DonAurelio May 2, 2023
3624250
Update xprof/tally.hpp
DonAurelio May 2, 2023
963a45f
suggestions
DonAurelio May 2, 2023
c7b910f
typos, cleaning
DonAurelio May 2, 2023
f91ce82
before formatting
DonAurelio May 3, 2023
23a2688
formatting
DonAurelio May 3, 2023
aeaeed6
merge maaster
DonAurelio May 3, 2023
7272161
cleaning
DonAurelio May 3, 2023
3f438e9
cleaning
DonAurelio May 3, 2023
f840f83
suggestions
DonAurelio Jun 12, 2023
979fe87
fix
DonAurelio Jun 12, 2023
230f4ab
Merge remote-tracking branch 'alcf/master'
DonAurelio Jun 12, 2023
9c0575b
fixed
DonAurelio Jun 12, 2023
e3dfcf9
Update btx_interval_model.yaml
DonAurelio Jun 12, 2023
ab077c4
set backend level via env variable
DonAurelio Jun 13, 2023
85ce7af
update
DonAurelio Jun 13, 2023
f1412e0
fix
DonAurelio Jun 13, 2023
a602ccc
merge thomas, brice updates
DonAurelio Jun 14, 2023
d237d11
update comment
DonAurelio Jun 14, 2023
66b8076
merge level selection by env variable
DonAurelio Jun 14, 2023
6f6ec1b
merge
DonAurelio Jun 14, 2023
f526973
--backend_level
DonAurelio Jun 16, 2023
e0dc689
suggestions
DonAurelio Jun 19, 2023
b9ea26a
suggestions
DonAurelio Jun 19, 2023
03245f7
update
DonAurelio Jun 19, 2023
ade64de
update
DonAurelio Jun 19, 2023
4b6c4e4
Merge branch 'master' into master
TApplencourt Jun 20, 2023
6107db1
update
DonAurelio Jun 20, 2023
d4022de
Update spliting to a more readable format
DonAurelio Jun 22, 2023
0f48c87
suggestions
DonAurelio Jun 23, 2023
15bd6df
update
DonAurelio Jun 23, 2023
34c737d
Merge remote-tracking branch 'alcf/master'
DonAurelio Jun 23, 2023
15092cf
Update utils/babeltrace_thapi.in
DonAurelio Jun 26, 2023
9badfed
Update utils/xprof_utils.hpp
DonAurelio Jun 26, 2023
0d5f106
Update xprof/tally.cpp
DonAurelio Jun 26, 2023
cd2f784
fix identation
DonAurelio Jun 26, 2023
cd4df68
implitic max value
DonAurelio Jun 26, 2023
9f413dc
add namespace
DonAurelio Jun 26, 2023
c6b6377
merge master branch
DonAurelio Jun 26, 2023
2c0eed0
fix merge resolution
DonAurelio Jun 26, 2023
fa2366f
Update utils/xprof_utils.hpp
Kerilk Jun 27, 2023
39cecea
Update xprof/tally.cpp
Kerilk Jun 27, 2023
c628345
Merge branch 'master' into master
TApplencourt Jun 27, 2023
e01eb69
add --backed-level option to command line help
DonAurelio Jun 27, 2023
f87333c
Merge branch 'master' into master
TApplencourt Jun 30, 2023
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
3 changes: 2 additions & 1 deletion utils/babeltrace_thapi.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ $options_tally = {
'display_mode' => [String, 'human'],
'display_metadata' => [FalseClass, false],
'display_name_max_size' => [Integer, 80],
'display_kernel_verbose' => [FalseClass, false]
'display_kernel_verbose' => [FalseClass, false],
'backend_level' => [String, ''],
}

def common_options(opts)
Expand Down
1 change: 0 additions & 1 deletion utils/xprof_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,3 @@ bt_message* create_traffic_message(const char *hostname, const process_id_t proc

return message;
}

37 changes: 20 additions & 17 deletions utils/xprof_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@
#include <string>
#include "babeltrace2/babeltrace.h"

enum backend_e{ BACKEND_UNKNOWN = 0,
BACKEND_ZE = 1,
BACKEND_OPENCL = 2,
BACKEND_CUDA = 3,
BACKEND_OMP_TARGET_OPERATIONS = 4,
BACKEND_OMP = 5,
BACKEND_HIP = 6 };

constexpr int backend_level[] = { 2, 2, 2, 2, 1, 0, 2 };

constexpr const char* backend_name[] = { "BACKEND_UNKNOWN",
"BACKEND_ZE",
"BACKEND_OPENCL",
"BACKEND_CUDA",
"BACKEND_OMP_TARGET_OPERATIONS",
"BACKEND_OMP",
"BACKEND_HIP" };
enum backend_e {
BACKEND_UNKNOWN = 0,
BACKEND_ZE = 1,
BACKEND_OPENCL = 2,
BACKEND_CUDA = 3,
BACKEND_OMP_TARGET_OPERATIONS = 4,
BACKEND_OMP = 5,
BACKEND_HIP = 6,
BACKEND_MAX,
};

constexpr const char* backend_name[] = {
"BACKEND_UNKNOWN",
"BACKEND_ZE",
"BACKEND_OPENCL",
"BACKEND_CUDA",
"BACKEND_OMP_TARGET_OPERATIONS",
"BACKEND_OMP",
"BACKEND_HIP",
};

typedef enum backend_e backend_t;
typedef unsigned backend_level_t;
Expand Down
2 changes: 2 additions & 0 deletions xprof/btx_tally_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
:type: integer_unsigned
- :name: display_kernel_verbose
:type: bool
- :name: backend_level
:type: string
44 changes: 41 additions & 3 deletions xprof/tally.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "tally.hpp"
#include <string>
#include <array>
#include <cassert>
#include <sstream> // std::stringstream, std::stringbuf

//! User data collection structure.
//! It is used to collect interval messages data, once data is collected,
Expand All @@ -7,6 +11,8 @@ struct tally_dispatch_s {
//! User params provided to the user component.
btx_params_t *params;

std::array<int, BACKEND_MAX>backend_level;
DonAurelio marked this conversation as resolved.
Show resolved Hide resolved

std::map<backend_level_t, std::set<const char *>> host_backend_name;
std::map<backend_level_t, std::set<const char *>> traffic_backend_name;

Expand All @@ -32,14 +38,46 @@ void print_metadata(std::vector<std::string> metadata) {
std::cout << value << std::endl;
}

int get_backend_id(std::string name) {
for(int i = 0; i < BACKEND_MAX; ++i)
// backend_name is located in xprof_utils.cpp
if (std::string{backend_name[i]} == name) return i;
return -1;
}

void btx_initialize_usr_data(void *btx_handle, void **usr_data) {
/* User allocates its own data structure */
*usr_data = new tally_dispatch_t;
auto *data = new tally_dispatch_t;
*usr_data = data;

/* Backend information must match enum backend_e in xprof_utils.hpp */
data->backend_level = {
2, // BACKEND_UNKNOWN
2, // BACKEND_ZE
2, // BACKEND_OPENCL
2, // BACKEND_CUDA
1, // BACKEND_OMP_TARGET_OPERATIONS
0, // BACKEND_OMP
2, // BACKEND_HIP
};
}

void btx_read_params(void *btx_handle, void *usr_data, btx_params_t *usr_params) {
tally_dispatch_t *data = (tally_dispatch_t *)usr_data;
data->params = usr_params;

// Consumes key:value pairs in the stringstream k1:v1,..,kn:vn
std::stringstream tokens{data->params->backend_level};
std::string tmp;
while (std::getline(tokens, tmp, ',')) {
std::stringstream tmp_string{tmp};
std::string k,v;
std::getline(tmp_string, k, ':');
int id = get_backend_id(k);
assert((id > 0) && "Backend not found. Please check --backend-level format.");
DonAurelio marked this conversation as resolved.
Show resolved Hide resolved
std::getline(tmp_string, v);
data->backend_level[id] = std::stoi(v);
}
}

void btx_finalize_usr_data(void *btx_handle, void *usr_data) {
Expand Down Expand Up @@ -127,7 +165,7 @@ static void host_usr_callback(void *btx_handle, void *usr_data, const char *host
tally_dispatch_t *data = (tally_dispatch_t *)usr_data;

TallyCoreTime a{dur, (uint64_t)err};
const int level = backend_level[backend_id];
const int level = data->backend_level[backend_id];
data->host_backend_name[level].insert(backend_name[backend_id]);
data->host[level][hpt_function_name_t(hostname, vpid, vtid, name)] += a;
}
Expand All @@ -154,7 +192,7 @@ static void traffic_usr_callback(void *btx_handle, void *usr_data, const char *h
tally_dispatch_t *data = (tally_dispatch_t *)usr_data;

TallyCoreByte a{(uint64_t)size, false};
const int level = backend_level[backend];
const int level = data->backend_level[backend];
data->traffic_backend_name[level].insert(backend_name[backend]);
data->traffic[level][hpt_function_name_t(hostname, vpid, vtid, name)] += a;
}
Expand Down
2 changes: 2 additions & 0 deletions xprof/tally.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <tuple>
#include <unordered_map>
#include <vector>
#include <string>
#include <array>

#include "json.hpp"
#include "my_demangle.h"
Expand Down
1 change: 1 addition & 0 deletions xprof/xprof.sh.erb.in
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ while (( "$#" )); do
-l | --timeline) shift; timeline=true ;;
-j | --json) shift; bt_tally_argv+=" --display_mode=json" ;;
-m | --tracing-mode) shift; tracing_mode=$1; shift ;;
--backend-level) shift; bt_tally_argv+=" --backend_level=$1"; shift ;;
--no-save) shift; procesing_mode="on-the-fly" ;;
--traced-ranks) shift; traced_ranks=$1; shift ;;
--asm) shift; asm=true ;;
Expand Down