Skip to content

Commit

Permalink
Add --nvidia option
Browse files Browse the repository at this point in the history
  • Loading branch information
cvonelm committed Mar 11, 2024
1 parent 9750d3c commit 7a89a87
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions include/lo2s/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ struct Config
std::vector<int64_t> syscall_filter;
// NEC SX-Aurora Tsubasa
bool use_nec;
// Nvidia CUPTI
bool use_nvidia;
std::chrono::microseconds nec_read_interval;
std::chrono::milliseconds nec_check_interval;
};
Expand Down
4 changes: 4 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void parse_program_options(int argc, const char** argv)
auto& sensors_options = parser.group("sensors options");
auto& io_options = parser.group("I/O recording options");
auto& nec_options = parser.group("NEC SX-Aurora Tsubasa recording options");
auto& nvidia_options = parser.group("Nvidia CUDA instrumentation options");

lo2s::Config config;

Expand Down Expand Up @@ -344,6 +345,8 @@ void parse_program_options(int argc, const char** argv)
.metavar("MSEC")
.default_value("100");

nvidia_options.toggle("nvidia", "Enable Nvidia CUPTI instrumentation");

nitro::options::arguments arguments;
try
{
Expand All @@ -370,6 +373,7 @@ void parse_program_options(int argc, const char** argv)
config.use_sensors = arguments.given("sensors");
config.use_block_io = arguments.given("block-io");
config.use_nec = arguments.given("nec");
config.use_nvidia = arguments.given("nvidia");
config.command = arguments.positionals();

if (arguments.given("help"))
Expand Down
14 changes: 7 additions & 7 deletions src/cupti/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <cupti.h>
extern "C"
{
#include <time.h>
#include <time.h>
#include <unistd.h>
}

Expand All @@ -52,7 +52,7 @@ static void CUPTIAPI bufferRequested(uint8_t** buffer, size_t* size, size_t* max

if (*buffer == NULL)
{
std::cerr << "Error: Out of memory.\n";
std::cerr << "Error: Out of memory.\n";
exit(-1);
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ static void CUPTIAPI bufferCompleted(CUcontext ctx, uint32_t streamId, uint8_t*
cuptiActivityGetNumDroppedRecords(ctx, streamId, &dropped);
if (dropped != 0)
{
std::cerr << "Dropped %u activity records.\n", (unsigned int)dropped;
std::cerr << "Dropped %u activity records.\n", (unsigned int)dropped;
}

free(buffer);
Expand Down Expand Up @@ -159,10 +159,10 @@ void CUPTIAPI callbackHandler(void* userdata, CUpti_CallbackDomain domain, CUpti

uint64_t timestampfunc()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
uint64_t res = ts.tv_sec * 1000000000 + ts.tv_nsec;
return res;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
uint64_t res = ts.tv_sec * 1000000000 + ts.tv_nsec;
return res;
}

extern "C" int InitializeInjection(void)
Expand Down
2 changes: 1 addition & 1 deletion src/monitor/scope_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ScopeMonitor::ScopeMonitor(ExecutionScope scope, MainMonitor& parent, bool enabl
add_fd(userspace_counter_writer_->fd());
}

if (is_process)
if (config().use_nvidia && is_process)
{
cupti_reader_ = std::make_unique<cupti::Reader>(parent.trace(), scope.as_process());
add_fd(cupti_reader_->fd());
Expand Down

0 comments on commit 7a89a87

Please sign in to comment.