@@ -20,11 +20,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020THE SOFTWARE.
2121*/
2222
23+ #include < dlfcn.h>
2324#include < math.h>
2425#include < sys/time.h>
2526
2627#include < algorithm>
2728#include < cstring>
29+ #include < filesystem>
2830#include < map>
2931#include < memory>
3032#include < stdexcept>
@@ -64,6 +66,22 @@ rdc_status_t rdc_module_init(uint64_t /*flags*/) {
6466 // before the tests are. Utilize an env var instead.
6567 return RDC_ST_DISABLED_MODULE ;
6668 }
69+
70+ Dl_info dl_info = {};
71+ RDC_LOG (RDC_DEBUG , " Checking if rocprofiler is available" );
72+ if (dladdr (reinterpret_cast <const void *>(rdc_module_init), &dl_info) != 0 ) {
73+ const std::filesystem::path rdc_path (dl_info.dli_fname );
74+ const auto profiler_metrics_path =
75+ rdc_path.parent_path ().parent_path ().parent_path () / " share/rocprofiler-sdk" ;
76+ const auto rocprofiler_exists = std::filesystem::exists (profiler_metrics_path);
77+ if (!rocprofiler_exists) {
78+ RDC_LOG (RDC_ERROR , " rocprofiler metrics are not available at " << profiler_metrics_path);
79+ return RDC_ST_FAIL_LOAD_MODULE ;
80+ }
81+ RDC_LOG (RDC_DEBUG , " rocprofiler metrics are available at " << profiler_metrics_path);
82+ setenv (" ROCPROFILER_METRICS_PATH" , profiler_metrics_path.c_str (), 0 );
83+ }
84+
6785 rocp_p = std::make_unique<amd::rdc::RdcRocpBase>();
6886 return RDC_ST_OK ;
6987}
@@ -98,7 +116,7 @@ rdc_status_t rdc_telemetry_fields_value_get(rdc_gpu_field_t* fields, const uint3
98116 // Bulk fetch fields
99117 std::vector<rdc_gpu_field_value_t > bulk_results;
100118
101- struct timeval tv {};
119+ struct timeval tv{};
102120 gettimeofday (&tv, nullptr );
103121 const uint64_t curTime = static_cast <uint64_t >(tv.tv_sec ) * 1000 + tv.tv_usec / 1000 ;
104122
0 commit comments