-
Notifications
You must be signed in to change notification settings - Fork 37
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
support for per-vGPU mode profiling #165
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ function GputopCSV(pretty_print) | |
this.endl = process.platform === "win32" ? "\r\n" : "\n"; | ||
|
||
this.term_row_ = 0; | ||
this.current_hw_id = 0; | ||
this.idle_flag = 0; | ||
|
||
this.console = { | ||
log: (msg) => { | ||
|
@@ -134,6 +136,59 @@ GputopCSV.prototype.list_metric_set_counters = function(metric) { | |
stderr_log.log("\nALL: " + all); | ||
} | ||
|
||
var ctx_hw_id_ = []; | ||
var vgpu_id_ = []; | ||
var map_vgpuID_hwID = [0]; | ||
|
||
GputopCSV.prototype.get_vgpu_id = function() { | ||
var vgpu_id; | ||
for (var i = 0; i < vgpu_id_.length; i++) { | ||
if (vgpu_id_[i] === parseInt(args.vgpu)) { | ||
vgpu_id = vgpu_id_[i]; | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please align this break statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my mistake, I have corrected it. |
||
} | ||
} | ||
return vgpu_id; | ||
} | ||
|
||
GputopCSV.prototype.update_vgpuID_hwID = function(hw_id) { | ||
|
||
hw_id.ctx_hw_id.forEach((ctx_hw_id, i) => { | ||
ctx_hw_id_.push(ctx_hw_id.toInt()); | ||
}); | ||
hw_id.vgpu_id.forEach((vgpu_id, i) => { | ||
vgpu_id_.push(vgpu_id.toInt()); | ||
}); | ||
|
||
|
||
var map_length = Math.max.apply(Math, vgpu_id_); | ||
|
||
for (var i = 0; i < map_length; i++ ) { | ||
map_vgpuID_hwID[vgpu_id_[i]] = ctx_hw_id_[i]; | ||
} | ||
vgpu_id_.sort(); | ||
|
||
if (args.vgpu === 'list') { | ||
if (vgpu_id_.length === 0) { | ||
stderr_log.log("\nNo vGPU is running now!"); | ||
} else { | ||
stderr_log.log("\nList of vGPU ID selectable with --vgpu=..."); | ||
for (var i = 0; i < vgpu_id_.length; i++) | ||
stderr_log.log(vgpu_id_[i]); | ||
} | ||
} else { | ||
var vgpu_id; | ||
vgpu_id = this.get_vgpu_id(); | ||
this.current_hw_id = map_vgpuID_hwID[vgpu_id]; | ||
|
||
if (this.current_hw_id === undefined) { | ||
stderr_log.error("Failed to look up to vGPU ID " + args.vgpu); | ||
process.exit(1); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
GputopCSV.prototype.update_features = function(features) | ||
{ | ||
if (features.supported_oa_uuids.length == 0) { | ||
|
@@ -241,6 +296,7 @@ GputopCSV.prototype.update_features = function(features) | |
var col_width = 0; | ||
|
||
if (this.pretty_print_csv_) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the newlines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my mistake, I have removed this line. |
||
if (counter.symbol_name === "Timestamp") { | ||
var units = "(ns)"; | ||
var camel_name = "TimeStamp"; | ||
|
@@ -350,6 +406,7 @@ GputopCSV.prototype.update_features = function(features) | |
this.column_titles_.map((line) => { | ||
this.stream.write(line + this.endl); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the newlines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my mistake, I have removed this line. |
||
if (this.pretty_print_csv_) | ||
this.stream.write(this.column_units_ + this.endl); | ||
}, | ||
|
@@ -362,6 +419,8 @@ GputopCSV.prototype.update_features = function(features) | |
} | ||
} | ||
|
||
var n_rows; | ||
|
||
function write_rows(metric, accumulator) | ||
{ | ||
/* Note: this ref[erence] counter is pre-dermined to be one with | ||
|
@@ -375,7 +434,7 @@ function write_rows(metric, accumulator) | |
stderr_log.assert(ref_accumulated_counter.counter === ref_counter, | ||
"Spurious reference counter state"); | ||
|
||
var n_rows = ref_accumulated_counter.updates.length; | ||
n_rows = ref_accumulated_counter.updates.length; | ||
|
||
if (n_rows <= 1) | ||
return; | ||
|
@@ -456,19 +515,42 @@ function write_rows(metric, accumulator) | |
} | ||
} | ||
|
||
var flag = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you find a better name for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I have renamed this parameter with "warning_once" and put it into GputopCSV instance. |
||
|
||
GputopCSV.prototype.notify_accumulator_events = function(metric, accumulator, events_mask) { | ||
if (events_mask & 1) //period elapsed | ||
this.accumulator_clear(accumulator); | ||
|
||
if (this.write_queued_) | ||
return; | ||
|
||
setTimeout(() => { | ||
this.write_queued_ = false; | ||
write_rows.call(this, metric, accumulator); | ||
}, 0.2); | ||
if (this.idle_flag < 4) { | ||
flag = 0; | ||
setTimeout(() => { | ||
this.write_queued_ = false; | ||
write_rows.call(this, metric, accumulator); | ||
}, 0.2); | ||
|
||
this.write_queued_ = true; | ||
this.write_queued_ = true; | ||
} else { | ||
if (flag === 0) { | ||
flag = 1; | ||
if (this.pretty_print_csv_) | ||
stderr_log.error("No context is running on this vGPU now"); | ||
else | ||
this.stream.write("No context is running on this vGPU now\n"); | ||
} | ||
|
||
for (var c = 0; c < this.counters_.length; c++) { | ||
var counter = this.counters_[c]; | ||
if (counter.record_data === true) { | ||
var accumulated_counter = | ||
accumulator.accumulated_counters[counter.cc_counter_id_]; | ||
n_rows = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going on here? Why bump the number of rows to 2? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my mistake, I have removed this line. |
||
accumulated_counter.updates.splice(0, n_rows); | ||
} | ||
} | ||
} | ||
} | ||
|
||
var parser = new ArgumentParser({ | ||
|
@@ -485,6 +567,16 @@ parser.addArgument( | |
} | ||
); | ||
|
||
parser.addArgument( | ||
[ '-vgpu', '--vgpu' ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can drop '-vgpu'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I have dropped '-vgpu'. |
||
{ | ||
help: "specific vgpu mode to observe (default 'list')", | ||
defaultValue: 'list', | ||
constant: 'list', | ||
nargs: '?' | ||
} | ||
); | ||
|
||
parser.addArgument( | ||
[ '-m', '--metrics' ], | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables should probably by part of the GputopCSV instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my mistake, I have put it into GputopCSV instance.