Changes

Jump to: navigation, search

GPU621/Pragmatic

876 bytes added, 23:26, 15 November 2016
Added notes for "How to: Use the Memory Window" section
===Pointers in OpenMP Parallel Region===
When debugging OpenMP in Visual Studio, you may encounter a situation when the values of your pointers in ''Watch'', ''Parallel Watch'', and ''Locals'' windows become either garbage, if when debugging in ''Release'' mode, or display ''<Unable to read memory>'' error (With 0xcccccccc memory address), if when debugging in ''Debug'' mode (0xcccccccc memory address is a dedicated memory address for uninitialized stack memory, in other words, this is where all uninitialized pointers point to in memory, for more information visit [https://en.wikipedia.org/wiki/Magic_number_(programming) Magic Number (Programming) Wiki]). It can take hours or even days to find the root cause and the solution that can address this unexpected behaviour.
This behaviour is caused, because when entering a parallel region, pointers that were initizalied prior to entering the parallel region are now point pointing to new, uninitialized , memory address, but only while in parallel region and only for ''Watch'', ''Parallel Watch'', and ''Locals'' windows. Operationally, all pointers will have their initialized values as you would expect. However, such behaviour makes it very hard to monitor pointers while debugging in parallel region.
This is where ''Memory'' window comes to the rescue.
 
Pointers can be monitored by tracking the memory address of each pointer '''before''' entering the parallel region.
 
 
===How to: Use the Memory Window===
 
To access ''Memory'' window select DEBUG > Windows > Memory > Memory 1/2/3/4 (Only during debugging).
 
To monitor the expression, select the expression in source code and drag it into ''Memory'' window (For variable, simply double click on the variable in the source code and drag selected text into ''Memory'' window). Alternatively, expression (Or address) can be entered into the ''Address'' field (In ''Memory'' window).
 
To change the format of memory contents, right click in the ''Memory'' window and select corresponding format.
 
To monitor live changes (To refresh ''Memory'' window automatically) in ''Memory'' window, right click in the ''Memory'' window and select ''Reevaluate Automatically''.
54
edits

Navigation menu