aclmdlRICaptureBegin

Note: This feature is for trial use and may be changed in later versions. It is not available in commercial products.

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

Starts capturing tasks delivered to a stream.

All tasks delivered to the specified stream between aclmdlRICaptureBegin and aclmdlRICaptureEnd are not executed immediately. Instead, they are stored in the internal model running instance of the system. These tasks are executed only when aclmdlRIExecute or aclmdlRIExecuteAsync is called to run model inference, thereby reducing the task delivery overhead on the host. After all tasks are executed, if the internal model is no longer needed, call aclmdlRIDestroy to destroy the resource in a timely manner.

aclmdlRICaptureBegin and aclmdlRICaptureEnd must be used in pairs, and the streams of the two APIs must be the same. Between the two APIs, you can call aclmdlRICaptureGetInfo to obtain the capture information and call aclmdlRICaptureThreadExchangeMode to switch the capture mode of the current thread. After aclmdlRICaptureEnd is called, you can call aclmdlRIDebugPrint to print the model information, which helps locate faults in maintenance and test scenarios.

If tasks captured between aclmdlRICaptureBegin and aclmdlRICaptureEnd (including the tasks themselves and task parameter information) need to be updated, you need to deliver the tasks that may be updated between aclmdlRICaptureTaskGrpBegin and aclmdlRICaptureTaskGrpEnd, mark the tasks with the task group flag, and update the input information of the tasks between aclmdlRICaptureTaskUpdateBegin and aclmdlRICaptureTaskUpdateEnd.

Tasks captured between aclmdlRICaptureBegin and aclmdlRICaptureEnd are temporarily stored in the internal model running instance of the system. As the number of tasks increases and event deduction and internal tasks are performed, more streams enter the capture state, which may result in higher stream consumption and insufficient concurrent scheduling resources. Therefore, you need to plan the use of scheduling resources in advance.

For details about the function, API call sequence, and sample code, see Building a Model Running Instance Based on the Capture Mode.

Prototype

aclError aclmdlRICaptureBegin(aclrtStream stream, aclmdlRICaptureMode mode)

Parameters

Parameter

Input/Output

Description

stream

Input

Stream.

mode

Input

Capture mode. This mode is used to limit the scope of unsafe functions, including aclrtMemset, aclrtMemcpy, aclrtMemcpy2d, and APIs (such as aclrtMemcpyAsync) that use non-page-locked host memory for asynchronous memory copy.

Returns

0 on success; else, failure. For details, see aclError.