# US 2019/0317831 A1 · Techniques for improved latency of thread synchronization mechanisms

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2019/0317831 A1
- Document ID: US20190317831A1
- Status: Published application
- Kind: A1
- Application number: 15/952,149
- Filed: 2018-04-12
- Published: 2019-10-17
- Earliest claimed: 2018-04-12
- Assignees: Advanced Micro Devices, Inc.
- Applicants: Advanced Micro Devices, Inc.
- Inventors: Amin Farmahini-Farahani; David A. Roberts; Nuwan Jayasena
- Web page: https://patentgrep.com/patent/US20190317831A1

## CPC

- G06F 9/52: Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F 9/528: {by using speculative mechanisms}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A memory fence or other similar operation is executed with reduced latency. An early fence operation is executed and acts as a hint to the processor executing the thread that executes the fence. This hint causes the processor to begin performing sub-operations for the fence earlier than if no such hint were executed. Examples of sub-operations for the fence include operations to make data written to by writes prior to the fence operation available to other threads. A resolving fence, which occurs after the early fence, performs the remaining sub-operations for the fence. By triggering some or all of the sub-operations for a memory fence that will occur in the future, the early fence operation reduces the amount of latency associated with that memory fence operation.

## Claims

### Claim 1

A method for executing a thread synchronization operation, the method comprising:
detecting that an early synchronization operation is to be performed for a thread;
initiating the early synchronization operation, causing early synchronization sub-operations for the early synchronization operation to be performed;
performing inter-synchronization operations, the inter-synchronization operations comprising operations between the early synchronization operation and a resolving synchronization operation in program order, at least one of the inter-synchronization operations being performed in an overlapping time period with the early synchronization sub-operations;
initiating a resolving synchronization operation, causing resolving synchronization sub-operations for the resolving synchronization operation to be performed; and
notifying a second thread that the resolving synchronization operation has been performed.

### Claim 2 (depends on 1)

The method of claim 1, wherein the resolving synchronization operation causes the thread to be stalled until the early synchronization sub-operations and the resolving synchronization sub-operations are complete.

### Claim 3 (depends on 1)

The method of claim 1, wherein the thread is allowed to proceed past, and is not blocked by, the early synchronization operation.

### Claim 4 (depends on 1)

The method of claim 1, wherein detecting that the early synchronization operation is to be performed for the thread comprises:
identifying an instruction explicitly requesting performance of the early synchronization operation.

### Claim 5 (depends on 1)

The method of claim 1 wherein detecting that the early synchronization operation is to be performed for the thread comprises:
automatically inserting an early synchronization operation into the instruction stream for the thread.

### Claim 6 (depends on 5)

The method of claim 5, wherein automatically inserting the early synchronization operation is performed in response to a prediction that the resolving synchronization operation will be performed.

### Claim 7 (depends on 5)

The method of claim 5, wherein automatically inserting the early synchronization operation is performed by a compiler in response to code analysis.

### Claim 8 (depends on 1)

The method of claim 1, wherein:
at least one of the early synchronization sub-operations and the resolving synchronization sub-operations include an operation for making data written by writes prior to the early synchronization operation in program order globally visible.

### Claim 9 (depends on 8)

The method of claim 8, wherein the operation for making data written by the writes prior to the early synchronization operation in program order globally visible is configured to flush dirty data from a cache local to a processor executing the thread into memory shared between multiple processors.

### Claim 10

A system for executing a thread synchronization operation, the system comprising:
a processor; and
a memory storing instructions that, when executed by the processor, cause the processor to execute the thread synchronization operation by:
detecting that an early synchronization operation is to be performed for a thread;
initiating the early synchronization operation, causing early synchronization sub-operations for the early synchronization operation to be performed;
performing inter-synchronization operations, the inter-synchronization operations comprising operations between the early synchronization operation and a resolving synchronization operation in program order, at least one of the inter-synchronization operations being performed in an overlapping time period with the early synchronization sub-operations;
initiating a resolving synchronization operation, causing resolving synchronization sub-operations for the resolving synchronization operation to be performed; and
notifying a second thread that the resolving synchronization operation has been performed.

### Claim 11 (depends on 10)

The system of claim 10, wherein the resolving synchronization operation causes the thread to be stalled until the early synchronization sub-operations and the resolving synchronization sub-operations are complete.

### Claim 12 (depends on 10)

The system of claim 10, wherein the thread is allowed to proceed past, and is not blocked by, the early synchronization operation.

### Claim 13 (depends on 10)

The system of claim 10, wherein detecting that the early synchronization operation is to be performed for the thread comprises:
identifying an instruction explicitly requesting performance of the early synchronization operation.

### Claim 14 (depends on 10)

The system of claim 10 wherein detecting that the early synchronization operation is to be performed for the thread comprises:
automatically inserting an early synchronization operation into the instruction stream for the thread.

### Claim 15 (depends on 14)

The system of claim 14, wherein automatically inserting the early synchronization operation is performed in response to a prediction that the resolving synchronization operation will be performed.

### Claim 16 (depends on 14)

The system of claim 14, wherein automatically inserting the early synchronization operation is performed by a compiler in response to code analysis.

### Claim 17 (depends on 10)

The system of claim 10, wherein:
at least one of the early synchronization sub-operations and the resolving synchronization sub-operations include an operation for making data written by writes prior to the early synchronization operation in program order globally visible.

### Claim 18 (depends on 17)

The system of claim 17, wherein the operation for making data written by the writes prior to the early synchronization operation in program order globally visible is configured to flush dirty data from a cache local to a processor executing the thread into memory shared between multiple processors.

### Claim 19

A system for executing a thread synchronization operation, the system comprising:
a first processor configured to execute a first thread;
a second processor configured to execute a second thread;
a shared memory accessible by both the first thread and the second thread; and
a memory storing instructions that, when executed by the processor, cause the processor to execute the thread synchronization operation by:
detecting that an early synchronization operation is to be performed for the first thread;
initiating the early synchronization operation, causing early synchronization sub-operations for the early synchronization operation to be performed;
performing inter-synchronization operations, the inter-synchronization operations comprising operations between the early synchronization operation and a resolving synchronization operation in program order, at least one of the inter-synchronization operations being performed in an overlapping time period with the early synchronization sub-operations;
initiating a resolving synchronization operation, causing resolving synchronization sub-operations for the resolving synchronization operation to be performed; and
notifying the second thread that the resolving synchronization operation has been performed.

### Claim 20 (depends on 19)

The system of claim 19, wherein the thread is allowed to proceed past, and is not blocked by, the early synchronization operation.
