File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -448,12 +448,6 @@ pi_result _pi_context::finalize() {
448
448
449
449
// Destroy the command list used for initializations
450
450
ZE_CALL (zeCommandListDestroy (ZeCommandListInit));
451
-
452
- // Destruction of some members of pi_context uses L0 context
453
- // and therefore it must be valid at that point.
454
- // Technically it should be placed to the destructor of pi_context
455
- // but this makes API error handling more complex.
456
- ZE_CALL (zeContextDestroy (ZeContext));
457
451
return PI_SUCCESS;
458
452
}
459
453
@@ -1830,9 +1824,22 @@ pi_result piContextRelease(pi_context Context) {
1830
1824
1831
1825
assert (Context);
1832
1826
if (--(Context->RefCount ) == 0 ) {
1827
+ auto ZeContext = Context->ZeContext ;
1828
+
1833
1829
// Clean up any live memory associated with Context
1834
1830
pi_result Result = Context->finalize ();
1831
+
1832
+ // We must delete Context first and then destroy zeContext because
1833
+ // Context deallocation requires ZeContext in some member deallocation of
1834
+ // pi_context.
1835
1835
delete Context;
1836
+
1837
+ // Destruction of some members of pi_context uses L0 context
1838
+ // and therefore it must be valid at that point.
1839
+ // Technically it should be placed to the destructor of pi_context
1840
+ // but this makes API error handling more complex.
1841
+ ZE_CALL (zeContextDestroy (ZeContext));
1842
+
1836
1843
return Result;
1837
1844
}
1838
1845
return PI_SUCCESS;
You can’t perform that action at this time.
0 commit comments