9.7.15.7. Parallel Synchronization and Communication Instructions: red.async
red.async
Asynchronous reduction operation.
Syntax
ptx
// Increment and Decrement reductions
red.async.sem.scope{.ss}.completion_mechanism.op.type [a], b, [mbar];
.sem = { .relaxed };
.scope = { .cluster };
.ss = { .shared::cluster };
.op = { .inc, .dec };
.type = { .u32 };
.completion_mechanism = { .mbarrier::complete_tx::bytes };
// MIN and MAX reductions
red.async.sem.scope{.ss}.completion_mechanism.op.type [a], b, [mbar];
.sem = { .relaxed };
.scope = { .cluster };
.ss = { .shared::cluster };
.op = { .min, .max };
.type = { .u32, .s32 };
.completion_mechanism = { .mbarrier::complete_tx::bytes };
// Bitwise AND, OR and XOR reductions
red.async.sem.scope{.ss}.completion_mechanism.op.type [a], b, [mbar];
.sem = { .relaxed };
.scope = { .cluster };
.ss = { .shared::cluster };
.op = { .and, .or, .xor };
.type = { .b32 };
.completion_mechanism = { .mbarrier::complete_tx::bytes };
// ADD reductions
red.async.sem.scope{.ss}.completion_mechanism.add.type [a], b, [mbar];
.sem = { .relaxed };
.scope = { .cluster };
.ss = { .shared::cluster };
.type = { .u32, .s32, .u64 };
.completion_mechanism = { .mbarrier::complete_tx::bytes };
red.async{.mmio}.sem.scope{.ss}.add.type [a], b;
.sem = { .release };
.scope = { .gpu, .sys };
.ss = { .global };
.type = { .u32, .s32, .u64, .s64 };Description
red.async is a non-blocking instruction which initiates an asynchronous reduction operation specified by .op, with the operand b and the value at the destination memory location specified by operand a.
red.async is performed in the generic proxy.
Operands
ais a destination address, and must be either a register, or of the formregister + immOff, as described in Addresses as Operands.bis a source value, of the type indicated by qualifier.type.mbaris an mbarrier object address.
Qualifiers
.mmioindicates whether this is an mmio Operation..semspecifies the memory ordering semantics as described in the Memory Consistency Model..scopespecifies the set of threads with which this instruction can directly synchronize..ssspecifies the state space of the destination operandaand the mbarrier operandmbar.- If
.ssis not specified, Generic Addressing is used. .completion_mechanismspecifies the mechanism for observing the completion of the asynchronous operation.- When
.completion_mechanismis.mbarrier::complete_tx::bytes: upon completion of the asynchronous operation, a complete-tx operation will be performed on the mbarrier object specified by the operandmbar, withcompleteCountargument equal to the amount of data stored in bytes. - When
.completion_mechanismis not specified: the completion of the store synchronizes with the end of the CTA. This instruction accesses its mbarrier operand using generic-proxy. .opspecifies the reduction operation.- The
.incand.decoperations return a result in the range [0..b]. .typespecifies the type of the source operandb.
Conditions
When .sem is .relaxed:
- The reduce operation is a relaxed memory operation.
- The complete-tx operation on the mbarrier has
.releasesemantics at.clusterscope. - The shared-memory addresses of the destination operand
aand the mbarrier operandmbarmust meet all of the following conditions: - They belong to the same CTA.
- The CTA to which they belong is different from the CTA of the executing thread, but must be within the same cluster.
- Otherwise, the behavior is undefined.
.mmiomust not be specified.- If
.ssis specified, it must be.shared::cluster. - If
.ssis not specified, generic addressing is used for operandsaandmbar. If the generic addresses specified do not fall within the address window of.shared::clusterstate space, the behavior is undefined. - If
.completion_mechanismis specified, it must be.mbarrier::complete_tx::bytes. - If
.completion_mechanismis not specified, it defaults to.mbarrier::complete_tx::bytes.
When .sem is .release:
- The reduce operation is a strong memory operation with
.releasesemantics at the scope specified by.scope. - If
.mmiois specified,.scopemust be.sys. - If
.ssis specified, it must be.global. - If
.ssis not specified, generic addressing is used for operanda. If the generic address specified does not fall within the address window of.globalstate space, the behavior is undefined. .completion_mechanismmust not be specified.
PTX ISA Notes
Introduced in PTX ISA version 8.1.
Support for .mmio qualifier, .release semantics, .global state space, and .gpu and .sys scopes introduced in PTX ISA version 8.7.
Target ISA Notes
Requires sm_90 or higher.
.mmio qualifier, .release semantics, .global state space, and .gpu and .sys scopes require sm_100 or higher.
Examples
ptx
red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.min.u32 [addr], b, [mbar_addr];
red.async.release.sys.global.add.u32 [addr], b;