Function: create_context

Applicable Products

Product

Supported (√/x)

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Explicitly creates a context in the calling process or thread.

For the Atlas 200I/500 A2 inference products , the context contains two streams: one default stream and one stream for internal synchronization.

For the Atlas training products , the context contains one default stream.

For the Atlas A2 training products / Atlas A2 inference products , the context contains one default stream.

For the Atlas inference products , in Ascend EP form, the context contains two streams: one default stream and one stream for internal synchronization.

For the Atlas A3 training products / Atlas A3 inference products , the context contains one default stream.

If acl.rt.set_device is not called in the application, when acl.rt.create_context is called for the first time, the system binds a default stream to the device based on the device ID passed by the API (one device is bound to only one default stream). Therefore, when acl.rt.create_context is called for the first time, the number of occupied streams is calculated as follows: Number of occupied streams = Number of default streams bound to the device + Number of streams contained in the context.

Prototype

Parameters

Parameter

Description

device_id

Int, ID of the device for which the context is to be created.

Return Values

Return Value

Description

context

Int, pointer address of the created context.

ret

Int, error code. 0 on success; else, failure.

Restrictions

The following application scenarios are supported:

Reference

For details about the API call sequence and examples, see Runtime Resource Allocation and Deallocation.