Using avAlloc and avStartWatch in C code

Using avAlloc and avStartWatch in C code

John suggested using the above to help in debugging. Here is my understanding--feel free to correct mistakes.

Question 1:

The manual says "Use avStartWatch
for arrays that are not dynamically allocated. Calling avStartWatch
results in more memory being used than with avAlloc,
since the array data needs to be copied to shared memory."

Q 1.A
Does the above statement mean
avStartWatch does not work with dynamically allocated arrays, even when the array size doesn't change after the initial allocation
or
For optimizing memory, use avStartWatch (avAlloc) for static (dynamic) arrays.

Q 1.B
I use dynamic arrays, whose size is determined at the start of the execution but doesn't change later.

Use of avAlloc seems to require (I am not changing code to use array_av rather than array_c.)

  1. the creation of an array (array_av)
  2. copy contents of array_c (array created in C) to array_av
  3. plot graph
  4. repeat copying every time array_c changes

Does the graph dynamically update when the contents of array_av change?

Question 2:

Create plot with avCreateGraph2D. array x, array y and the plot cannot be viewed simulataneously.
How does one display simulataneously arrays x, y and the plot in the same window?

11 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Q1.A: avStartWatch will work for dynamically allocated arrays (as long as the array size and location doesn't change).Q1.B: I'm not sure what array_av vs array_c is. The basic idea of avAlloc is that you use it instead of whatever your current mechanism ofallocatingmemory on the heap (e.g. malloc). avAlloc will return a block of memory that can be accessed out of process. This allows the Viewer to peak at the array without copying the buffer each time. If you're not using avAlloc, i.e. avStartWatch, a copy of the array is created (again in a shared memory region) and the program has to initiate an update whenever you want the new values to be viewable.Q2: This is possible, but it takes a lot more setup than just creating a graph with one array. Take a look at some of the data examples included with AV. There are some that show multiple array plots in one graph. If you see something close to what you want, you can use it as the basis for a "template.xml" file. Basically it's an an xml that defines the graph, but with the data (from your arrays) plugged in later. This is covered in the help.John

Thanks John. All my code uses malloc and is portable across platforms. To retain this portability, prefer not to use avAlloc.

Q.1.B I'm not sure what array_av vs array_c is
array_c is created using malloc
array_av is created using avAlloc

Q.2 What I wanted to ask was:

When one creates a XY plot using data in arrays x and y, the window displays only the plot.

Is it possible to display the data in arrays x and y & the XY plot in the same window? So one can view the data and the plot simultaneously.

Q.1.B: To keep portability, you could just do something like this:#ifndef AV_SUPPORTED#define avAlloc malloc#endifBut anyway, you can start out with the avStartWatch and see if that works. Should be fine unless you're dealing with a really large array.Q.2: Ok, I get you! Something like the old Compaq Array Visualizer where you had the split window with the graph in one pane and the data grid in the other?That was dropped in the Intel product. Since Intel AV could be displaying many array datasets in one graph, it wasn't clear which array should be shown in the grid view. So it switched to where you can select array objects in the left navigation pane (and see the grid view) or select a graph object (and see the graph).John

Q.1.B: To keep portability, you could just do something like this:#ifndef AV_SUPPORTED#define avAlloc malloc#endif
This is a good suggestion. In some functions, end up using negative indices--so move the array pointer forward and this will probably mess up the AV. Hence the initial idea of using avAlloc to create array_av and then copying over the data when array_c changes.
Of course, I can define another array pointer and change that.

double *array_c;

#ifdef AV_SUPPORTED create array_av with avAlloc
array_c = array_av; // make copy of pointer to array_av
#else
create array_c with malloc
#endif

But
anyway, you can start out with the avStartWatch and see if that works.
Should be fine unless you're dealing with a really large array.

What would you call "a really large array?"

What "large" is will depend on things like how much memory you have (if the extra copy of the array ends up using all the physical memory on your box, you'll end up paging a lot which will slow things down). Also for big arrays there will be a pause every time you call avUpdate since it will need to copy the array again.John

John:

avStartWatch did not work. avAlloc worked.
Now I can plot and display in 2D.
Thanks for your help.

How do I do the following in the same window?
1. Display more than one array on the y-axis.
2. Display grid lines corresponding to the major and minor tick marks.
3. Display the data in one panel and the graph in another panel?

Went through the documentation and the samples but could not see any simple solutions. Couple of examples display more than one array on the y-axis, one displays grid lines corresponding to the major tick marks, no example for 3.

While I am comfortable with programming, no experience with most of what is used. What is the easiest way to implement what I need?

Ideal would be a function like avCreateGraph2D with the necessary options.

Best

Hey Nag,See attached. This is just a small tweak of one of the sample data files included with AV. Three one-dimensional arrays graphed as XY plots. The change from the sample is that I modified the Minor Tick mark properties of the X & Y axis so that the shorter tick marks show up.Displaying multi-panel graphs is a bit trickier. I'd start with one panel graphs first!John

Thanks John. Did you miss attaching the file?
I do not need multi-panel graphs; just multiple arrays in the same graph.

Sorry, here it is.

Fichiers joints: 

Fichier attachéTaille
Télécharger threesin2.xml100.34 Ko

Hello all,

I have the same problem of array visualizer not working in intel visual fortran.
How can I use the functions avAlloc and avStartWatch to help in debugging?

THanks in advance for your answer.
Samba.

Connectez-vous pour laisser un commentaire.