Dynamic Memory Fence Selection for Thread Context

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Memory fence instructions in multi-processor systems are computationally expensive due to their long latency, especially when ensuring global visibility of memory accesses across multiple hardware threads, which can lead to inefficiencies in execution.

Innovation Solution

A method to dynamically assign either a lightweight or heavyweight memory fence based on whether a program is executed on a single hardware thread or multiple hardware threads, replacing heavyweight fences with lightweight ones when executing on a single thread to reduce computational overhead.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a heavy-weight memory fence is used to guarantee global visibility of memory accesses across multiple hardware threads, then memory access ordering is ensured, but execution latency increases significantly

Engineering Contradiction:
Improvememory access ordering guaranteeVSAvoidexecution latency
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system dynamically selects between light-weight and heavy-weight memory fence instructions based on the actual execution context (single-threaded vs. multi-threaded). This dynamic adaptation allows the system to use the minimal necessary fencing mechanism for each situation, reducing unnecessary latency while maintaining correctness.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The invention changes the parameter of memory fence weight (light vs. heavy) based on the threading context. By analyzing whether the program will execute on a single or multiple hardware threads, the system selects the appropriate fence intensity, transforming a static fencing approach into a parameter-adjustable one that optimizes for both correctness and performance.

Inventive Principle:
Principle #35Parameter changes

2Loss of time

If a light-weight memory fence is used for single hardware thread execution, then execution latency is reduced, but global memory visibility guarantee is lost

Engineering Contradiction:
Improveexecution latencyVSAvoidglobal memory visibility guarantee
Core Design Contradiction:
Loss of timeVSReliability

Solution Approach 1:

The system dynamically adapts the memory fence strength to match the execution context. When single-threaded execution is detected, light-weight fences are used which provide sufficient ordering guarantees for that context without the overhead of heavy-weight fences. When multi-threaded execution is detected, heavy-weight fences are used to ensure global visibility.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The invention uses light-weight memory fence instructions (cheaper, shorter latency operations) when appropriate for the execution context. These light-weight fences provide the necessary memory ordering guarantees for single-threaded execution without the computational expense of heavy-weight fences, effectively using the minimal necessary resource for each situation.

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

3Reliability

If heavy-weight memory fences are used in multi-threaded programs, then memory coherence across threads is maintained, but processor efficiency decreases

Engineering Contradiction:
Improvememory coherenceVSAvoidprocessor efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The system dynamically determines the threading context and adjusts memory fence usage accordingly. By detecting whether a program will execute on multiple hardware threads, the system can apply heavy-weight fences only when necessary for memory coherence, rather than universally applying them to all execution contexts, thus maintaining efficiency.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The invention applies different quality levels of memory fencing (light vs. heavy) to different execution contexts. Instead of using a uniform heavy-weight approach everywhere, the system locally adapts the fencing strength to match the actual threading requirements, providing strong fencing only where multi-threaded execution occurs and lighter fencing elsewhere.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS10761890B2Optimizing memory fences based on workload
Publication Date: 2020.09.01 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US10761890B2 patent drawing
  • US10761890B2 patent drawing
  • US10761890B2 patent drawing

AI summary

A method, computer program product, and apparatus for optimizing memory fences based on workload are provided. The method includes determining whether to execute a target program on a single hardware thread or a plurality of hardware threads. The method also includes assigning one of a light-weight memory fence and a heavy-weight memory fence as a memory fence in the target program based on whether to execute the target program on the single hardware thread or the plurality of hardware threads. The method further includes assigning the light-weight memory fence in response to determining to execute the target program on the single hardware thread, and the heavy-weight memory fence is assigned in response to determining to execute the target program on the plurality of hardware threads.