1 /*
2 * Copyright (C) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
9
10 #include "shared/source/helpers/debug_helpers.h"
11
12 namespace NEO {
13
DirectSubmissionDiagnosticsCollector(uint32_t executions,bool storeExecutions,int32_t ringBufferLogData,int32_t semaphoreLogData,int32_t workloadMode,bool cacheFlushLog,bool monitorFenceLog)14 DirectSubmissionDiagnosticsCollector::DirectSubmissionDiagnosticsCollector(uint32_t executions,
15 bool storeExecutions,
16 int32_t ringBufferLogData,
17 int32_t semaphoreLogData,
18 int32_t workloadMode,
19 bool cacheFlushLog,
20 bool monitorFenceLog)
21 : storeExecutions(storeExecutions) {
22 UNRECOVERABLE_IF(executions == 0);
23 executionList.resize(executions);
24 executionsCount = executions;
25 std::stringstream value;
26 value << std::dec << "mode-" << workloadMode << "_executions-" << executions;
27 value << "_ring_" << ringBufferLogData << "_semaphore_" << semaphoreLogData;
28 value << "_cacheflush-" << cacheFlushLog << "_monitorfence-" << monitorFenceLog;
29 std::stringstream filename;
30 filename << "ulls_diagnostic_" << value.str() << ".log";
31 logFile = IoFunctions::fopenPtr(filename.str().c_str(), "at");
32 UNRECOVERABLE_IF(logFile == nullptr);
33 IoFunctions::fprintf(logFile, "%s\n", value.str().c_str());
34 }
35
storeData()36 void DirectSubmissionDiagnosticsCollector::storeData() {
37 auto initDelta = diagnosticModeDiagnosticTime - diagnosticModeAllocationTime;
38 int64_t initTimeDiff =
39 std::chrono::duration_cast<std::chrono::microseconds>(initDelta).count();
40
41 IoFunctions::fprintf(logFile, "From allocations ready to exit of OS submit function %lld useconds\n", initTimeDiff);
42
43 if (storeExecutions) {
44 for (uint32_t execution = 0; execution < executionsCount; execution++) {
45 DirectSubmissionSingleDelta &delta = executionList[execution];
46 std::stringstream value;
47 value << std::dec << " execution: " << execution;
48 value << " total diff: " << delta.totalTimeDiff << " nsec"
49 << " dispatch-submit: " << delta.dispatchSubmitTimeDiff << " nsec"
50 << " submit-wait: " << delta.submitWaitTimeDiff << " nsec";
51 IoFunctions::fprintf(logFile, "%s\n", value.str().c_str());
52 }
53 }
54 }
55
56 } // namespace NEO
57