Version Query Mechanism

Runtime provides multi-layer version query APIs to help applications obtain environment information at runtime and implement compatibility adaptation.

Runtime Version Query

Use the aclsysGetVersionNum API to query the Runtime version number. Pass the package name runtime.

char pkgName[] = "runtime";
int32_t versionNum;
aclsysGetVersionNum(pkgName, &versionNum);

printf("Runtime Version Num: %d\n", versionNum);

The returned versionNum is an integer value that complies with the semantic versioning rules. This facilitates version comparison.

Version Part

Weight

Description

major

10000000

Incompatible API changes

minor

100000

Backward compatible function addition

patch

1000

Backward compatible issue resolution

Formula for calculating the official version

versionNum = major × 10000000 + minor × 100000 + patch × 1000

Example

Version string

Compute Process

versionNum

9.0.0

9 × 10000000 + 0 × 100000 + 0 × 1000

90000000

8.5.1

8 × 10000000 + 5 × 100000 + 1 × 1000

80501000

Driver Version Query

Runtime depends on the drive strength. For some features, the driver version needs to be checked for compatibility. You can pass the driver package name to query the driver version.

char pkgName[] = "driver"; // Query the driver version. Use "driver".
int32_t versionNum;
aclsysGetVersionNum(pkgName, &versionNum);
printf("Package Version Num: %d\n", versionNum);

Runtime Feature Query

Use aclrtGetDevFeature to query the features supported by the device and implement conditional adaptation of features.

int32_t deviceId = 0;
aclrtSetDevice(deviceId);

// Query whether a feature is supported.
int32_t isSupported = 0;
aclrtGetDevFeature(deviceId, ACL_FEATURE_XXX, &isSupported);

if (isSupported) {
    // Use the new feature.
} else {
    // Use the compatibility solution.
}