Counter API and Samples Updates (#410)

* Update include/rocprofiler-sdk/{counters,profile_config}.h

- use rocprofiler_agent_id_t instead of rocprofiler_agent_t

* Update samples

- use rocprofiler-sdk::rocprofiler-sdk instead of rocprofiler::rocprofiler in cmake
- api_callback_tracing sample roctxProfiler{Pause,Resume}
- api_callback_tracing sample uses ROCTx
- updates to use rocprofiler_agent_id_t

* Update run-ci.py

- exclude rocprofiler-sdk-tool from samples (no sample uses that code)

* Update lib/rocprofiler-sdk-tool/tool.cpp

- Update rocprofiler_iterate_agent_supported_counters to use agent ID

* Update lib/rocprofiler-sdk/counters/core.*

- profile_config has pointer to agent instead of copy

* Update lib/rocprofiler-sdk/agent.*

- provide get_agent(...) func via rocp agent id

* Update lib/rocprofiler-sdk/{buffer,callback}_tracing.cpp

- return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED for enums missing implementation

* Update lib/rocprofiler-sdk/counters.cpp

- update to use rocprofiler_agent_id_t instead of rocprofiler_agent_t

* Update lib/rocprofiler-sdk/profile_config.cpp

- update to use rocprofiler_agent_id_t instead of rocprofiler_agent_t

* Update source/docs

- requirements.txt + install reqs in cmake

* Bump version to 0.1.0

* Update samples/api_callback_tracing/CMakeLists.txt

- LD_LIBRARY_PATH for test

* Update test/rocprofv3/tracing/CMakeLists.txt

- reorder validation files so memory copy comes first

* Update lib/rocprofiler-sdk-tool/tool.cpp

- logging for flushing buffers
- variables for buffer_size and buffer_watermark
  - increase the watermark to a full buffer
- use dedicated threads for each buffer

* Update lib/rocprofiler-sdk-tool/CMakeLists.txt

- test sets ROCPROF_LOG_LEVEL and ROCPROFILER_LOG_LEVEL to info

* Remove lib/rocprofiler-sdk-tool/trace_buffer.hpp

* Update lib/rocprofiler-sdk-tool/CMakeLists.txt

- drop log level to warning when leak sanitizer is enabled (produces small memory leak)
Cette révision appartient à :
Jonathan R. Madsen
2024-01-25 23:47:40 -06:00
révisé par GitHub
Parent c641749fe6
révision 9a8b6f6b7b
27 fichiers modifiés avec 341 ajouts et 470 suppressions
+31 -5
Voir le fichier
@@ -22,7 +22,8 @@
#include "client.hpp"
#include "hip/hip_runtime.h"
#include <hip/hip_runtime.h>
#include <rocprofiler-sdk-roctx/roctx.h>
#include <chrono>
#include <cstdio>
@@ -65,7 +66,7 @@ verify(int* in, int* out, int M, int N);
} // namespace
__global__ void
transpose_a(int* in, int* out, int M, int N);
transpose_a(const int* in, int* out, int M, int N);
void
run(int rank, int tid, hipStream_t stream, int argc, char** argv);
@@ -76,6 +77,8 @@ main(int argc, char** argv)
client::setup(); // currently does nothing
// client::start(); // currently will fail
auto range_id = roctxRangeStart("main");
int rank = 0;
for(int i = 1; i < argc; ++i)
{
@@ -114,18 +117,34 @@ main(int argc, char** argv)
{
std::vector<std::thread> _threads{};
std::vector<hipStream_t> _streams(nthreads);
roctxMark("stream creation");
for(size_t i = 0; i < nthreads; ++i)
HIP_API_CALL(hipStreamCreate(&_streams.at(i)));
roctxMark("thread creation");
for(size_t i = 1; i < nthreads; ++i)
_threads.emplace_back(run, rank, i, _streams.at(i), argc, argv);
run(rank, 0, _streams.at(0), argc, argv);
roctxMark("thread sync");
for(auto& itr : _threads)
itr.join();
roctxMark("stream destroy");
for(size_t i = 0; i < nthreads; ++i)
HIP_API_CALL(hipStreamDestroy(_streams.at(i)));
}
HIP_API_CALL(hipDeviceSynchronize());
auto tid = roctx_thread_id_t{};
// get the thread id recognized by rocprofiler-sdk from roctx
roctxGetThreadId(&tid);
// pause API tracing
roctxProfilerPause(tid);
// would not expect below to show up in profiler (depends on tool)
HIP_API_CALL(hipDeviceReset());
// resume API tracing
roctxProfilerResume(tid);
roctxRangeStop(range_id);
client::stop();
client::shutdown();
@@ -134,7 +153,7 @@ main(int argc, char** argv)
}
__global__ void
transpose_a(int* in, int* out, int M, int N)
transpose_a(const int* in, int* out, int M, int N)
{
__shared__ int tile[shared_mem_tile_dim][shared_mem_tile_dim];
@@ -148,6 +167,10 @@ transpose_a(int* in, int* out, int M, int N)
void
run(int rank, int tid, hipStream_t stream, int argc, char** argv)
{
auto run_name = std::stringstream{};
run_name << __FUNCTION__ << "(" << rank << ", " << tid << ")";
roctxRangePush(run_name.str().c_str());
unsigned int M = 4960 * 2;
unsigned int N = 4960 * 2;
if(argc > 2) nitr = atoll(argv[2]);
@@ -157,8 +180,9 @@ run(int rank, int tid, hipStream_t stream, int argc, char** argv)
std::cout << "[" << rank << "][" << tid << "] M: " << M << " N: " << N << std::endl;
_lk.unlock();
std::default_random_engine _engine{std::random_device{}() * (rank + 1) * (tid + 1)};
std::uniform_int_distribution<int> _dist{0, 1000};
auto _seed = std::random_device{}() * (rank + 1) * (tid + 1);
auto _engine = std::default_random_engine{_seed};
auto _dist = std::uniform_int_distribution<int>{0, 1000};
size_t size = sizeof(int) * M * N;
int* inp_matrix = new int[size];
@@ -210,6 +234,8 @@ run(int rank, int tid, hipStream_t stream, int argc, char** argv)
delete[] inp_matrix;
delete[] out_matrix;
roctxRangePop();
}
namespace