Skip to content

Commit 95eb128

Browse files
authored
minor cleanup (#372)
1 parent e925cb4 commit 95eb128

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

docs/controls.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,14 +707,14 @@ The Intercept Layer for OpenCL Applications will wait for this many milliseconds
707707

708708
### Execution Controls
709709

710-
##### `ExitOnEnqueueCount` (uint64_t)
711-
712-
If set to a nonzero value, the Intercept Layer for OpenCL Applications will exit the application on achieved enqueue count. This can be used to debug sporadic issues in applications. In case issue is not visible in identified faulting kernel, not needed to wait application normal exit
713-
714710
##### `NoErrors` (bool)
715711

716712
If set to a nonzero value, the Intercept Layer for OpenCL Applications will cause all OpenCL APIs to return a successful error status.
717713

714+
##### `ExitOnEnqueueCount` (uint64_t)
715+
716+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will exit the application when the enqueue counter reaches the specified value. This can be useful to debug sporadic issues by exiting an application immediately, without needing to wait for the application to exit normally.
717+
718718
##### `NullContextCallback` (bool)
719719

720720
If set to a nonzero value, the Intercept Layer for OpenCL Applications will force the context callback to be NULL. With both context callback logging and NULL context callback set, the context callback will still be logged, but any application context callback will not be called.

intercept/src/controls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ CLI_CONTROL( cl_uint, AubCaptureStartWait, 0, "The
172172
CLI_CONTROL( cl_uint, AubCaptureEndWait, 0, "The Intercept Layer for OpenCL Applications will wait for this many milliseconds before ending aub capture.")
173173

174174
CLI_CONTROL_SEPARATOR( Execution Controls: )
175-
CLI_CONTROL( uint64_t, ExitOnEnqueueCount, 0, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will exit the application on achieved enqueue count. This can be used to debug sporadic issues in applications. In case issue is not visible in identified faulting kernel, not needed to wait application normal exit")
176175
CLI_CONTROL( bool, NoErrors, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will cause all OpenCL APIs to return a successful error status." )
176+
CLI_CONTROL( uint64_t, ExitOnEnqueueCount, 0, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will exit the application when the enqueue counter reaches the specified value. This can be useful to debug sporadic issues by exiting an application immediately, without needing to wait for the application to exit normally." )
177177
CLI_CONTROL( bool, NullContextCallback, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will force the context callback to be NULL. With both context callback logging and NULL context callback set, the context callback will still be logged, but any application context callback will not be called." )
178178
CLI_CONTROL( bool, FinishAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications inserts a call to clFinish() after every enqueue. The command queue that the command was just enqueued to is passed to clFinish(). This can be used to debug possible timing or resource management issues and will likely impact performance." )
179179
CLI_CONTROL( bool, FlushAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications inserts a call to clFlush() after every enqueue. The command queue that the command was just enqueued to is passed to clFlush(). This can also be used to debug possible timing or resource management issues and is slightly less obtrusive than FinishAfterEnqueue but still will likely impact performance. If both FinishAfterEnqueue and FlushAfterEnqueue are nonzero then the Intercept Layer for OpenCL Applications will only insert a call to clFinish() after every enqueue, because clFinish() implies clFlush()." )

intercept/src/intercept.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,18 +1947,26 @@ inline uint64_t CLIntercept::getEnqueueCounter() const
19471947

19481948
inline uint64_t CLIntercept::incrementEnqueueCounter()
19491949
{
1950-
uint64_t enqueueCounter = m_EnqueueCounter.load();
1951-
if( enqueueCounter != 0 ) {
1950+
if( m_Config.ExitOnEnqueueCount != 0 )
1951+
{
1952+
uint64_t enqueueCounter = m_EnqueueCounter.load();
19521953
if( enqueueCounter >= m_Config.ExitOnEnqueueCount )
19531954
{
1954-
log("Exit enqueue counter " + std::to_string(enqueueCounter) + " reached - exiting the application...\n");
1955+
// Note: we need to release the mutex before calling exit:
1956+
{
1957+
std::lock_guard<std::mutex> lock(m_Mutex);
1958+
logf("Exit enqueue counter reached (%" PRIu64 " >= %" PRIu64 "): exiting the application.\n",
1959+
enqueueCounter,
1960+
m_Config.ExitOnEnqueueCount);
1961+
}
19551962
exit(0);
19561963
}
19571964
}
19581965

19591966
uint64_t reportInterval = m_Config.ReportInterval;
19601967
if( reportInterval != 0 )
19611968
{
1969+
uint64_t enqueueCounter = m_EnqueueCounter.load();
19621970
if( enqueueCounter != 0 && enqueueCounter % reportInterval == 0 )
19631971
{
19641972
report();

0 commit comments

Comments
 (0)