Intel® Advisor User Guide

ID 766448
Date 3/22/2024
Public
Document Table of Contents

Memory Reuse

Occurs when two tasks write to a shared memory location. That is, a task writes to a variable with a new value but does not read the same value generated by a prior task.

One of the following has occurred:

Problem type: Memory reuse

Problem type: Memory reuse

ID

Code Location

Description

1

Allocation site

If present, and if the memory involved is heap memory, represents the location and associated call stack when the memory was allocated.

2

Parallel site

If present, represents the location and associated call stack of the parallel site containing the Memory Reuse problem.

3

Read

Represents the instruction and associated call stack of the first access if it is a memory read.

4

Write

Represents the instruction and associated call stack of the second access if it is a memory write.

5

Write

Represents the instruction and associated call stack of the first access if it is a memory write.

Example

int global;
void main()
{
    ANNOTATE_SITE_BEGIN(reuse_site);    // Begin parallel site
        ANNOTATE_TASK_BEGIN(task111);
            global = 111;               // Read and/or Write
            assert(global == 111);
        ANNOTATE_TASK_END();
        ANNOTATE_TASK_BEGIN(task222);
            global = 222;               // Write
            assert(global == 222);
        ANNOTATE_TASK_END();
    ANNOTATE_SITE_END();
}

In this example, two tasks use the same global variable. Each task does not read or communicate the value produced by the other task.

Some Possible Correction Strategies

Change the tasks to have their own private variables rather than sharing a variable.