Skip to content

Commit f23ec0e

Browse files
[PTI-SDK] Update dlworkloads, fix libpti_view segv (#72)
* Update dlworkloads with fix for segv on onednn >= 2024.0.0 * Fix libpti_view segv when the collector is not able to initialize. This usually occurs when the graphics drivers are not installed, or there is no GPU in the system. Signed-off-by: Schilling, Matthew <[email protected]> Co-authored-by: Aswani, Mahesh <[email protected]>
1 parent dda4731 commit f23ec0e

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

sdk/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.4
1+
0.3.5

sdk/samples/dlworkloads/main.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ void PrintUsage()
3838
std::cout << std::endl;
3939
std::cout << "It is supposed that this application will be updated frequently, so this might be not the latest one." << std::endl;
4040
std::cout << std::endl;
41-
#if __LIBSYCL_MAJOR_VERSION >= 7
42-
std::cerr << "Notice: A portion of this sample was not build. To build the whole sample, revert to older oneAPI release (<= 2023.2.0)" << std::endl;
43-
#endif
4441
}
4542

4643
void run(sycl::queue *q)

sdk/samples/dlworkloads/model_mixedprogramming.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ TinyTensor run_model_mixedprogramming(TinyTensor inp, sycl::queue *q)
1515
TinyTensor outp = run_syclkernel_operation_scaledown(inp, q);
1616
GlobalDeviceMemoryManager().free(inp.data);
1717

18-
// TODO([email protected]): Fails when run with XPTI tracing. We
19-
// need to figure out a way to uncomment this. It crashes PTI-SDK and
20-
// Unitrace built with OneAPI/ICPX >= 2024.0.0 .
21-
// the next operation uses oneDNN for conv2d
22-
#if __LIBSYCL_MAJOR_VERSION < 7
2318
inp = outp;
2419
outp = run_onednn_operation_conv2d(inp, q);
2520
GlobalDeviceMemoryManager().free(inp.data);
26-
#endif
2721

2822
// next operation uses oneMKL
2923
inp = outp;

sdk/samples/dlworkloads/operation_onednn.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
#include "operation_onednn.h"
1010
#include "utils.h"
11+
#include "device_memory.h"
1112

1213
// code as simple as possible for the demo
1314
namespace {
1415
inline auto& Conv2dWeightsInstance() {
1516
static TinyTensor conv2d_weights(0, 0, 0, 0);
1617
return conv2d_weights;
1718
}
18-
} // namespace
19+
} // namespace
1920

2021
void onednn_prepare_weights(int oc, int ic, int ks, sycl::queue *q)
2122
{
@@ -84,6 +85,7 @@ TinyTensor run_onednn_operation_conv2d(const TinyTensor& inp, sycl::queue *q)
8485
);
8586

8687
dnnl::primitive_attr pattr;
88+
pattr.set_scratchpad_mode(dnnl::scratchpad_mode::user);
8789
auto conv_pd = dnnl::convolution_forward::primitive_desc(
8890
eng,
8991
dnnl::prop_kind::forward_inference,
@@ -119,21 +121,18 @@ TinyTensor run_onednn_operation_conv2d(const TinyTensor& inp, sycl::queue *q)
119121
assert(conv_pd.dst_desc() == dst_mem.get_desc());
120122
assert(conv_pd.weights_desc() == weights_mem.get_desc());
121123

122-
int scratchpad_size = conv_pd.scratchpad_desc().get_size();
123-
static bool warning_shown = false;
124-
if (scratchpad_size == 0) {
125-
if (!warning_shown) {
126-
warning_shown = true;
127-
// std::cout << __FILE__ << ":" << __LINE__;
128-
// std::cout << " we need a onednn case that scratchpad_size > 0, to verify if it can be allocated within onednn for sycl grapch capture mode" << std::endl;
129-
}
130-
}
124+
dnnl::memory::desc scratchpad_md = conv_pd.scratchpad_desc();
125+
auto scratchpad_size = scratchpad_md.get_size();
126+
auto* scratchpad_ptr = GlobalDeviceMemoryManager().alloc(scratchpad_size/sizeof(float)+1);
127+
dnnl::memory scratchpad(scratchpad_md, eng, scratchpad_ptr);
131128

132129
auto conv = dnnl::convolution_forward(conv_pd);
133130
conv.execute(s,
134131
{{DNNL_ARG_SRC, src_mem},
135132
{DNNL_ARG_WEIGHTS, weights_mem},
136-
{DNNL_ARG_DST, dst_mem}});
133+
{DNNL_ARG_DST, dst_mem},
134+
{DNNL_ARG_SCRATCHPAD, scratchpad}});
137135

136+
GlobalDeviceMemoryManager().free(scratchpad_ptr);
138137
return outp;
139138
}

sdk/src/view_handler.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ struct PtiViewRecordHandler {
146146
virtual ~PtiViewRecordHandler() {
147147
overhead::overhead_collection_enabled = false;
148148
DisableTracing();
149-
collector_->DisableTracing();
150-
delete collector_;
149+
if (collector_) {
150+
collector_->DisableTracing();
151+
delete collector_;
152+
}
151153
stop_consumer_thread_ = true;
152154
buffer_queue_.ResetBufferDepth();
153155
buffer_queue_.Push(ViewBuffer{}); // Stop consumer

0 commit comments

Comments
 (0)