<div><div dir="auto">MPI_Win_{get,set}_name might be an even simpler way to do that. </div></div><div dir="auto"><br></div><div dir="auto">Jeff</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 18, 2019 at 1:04 AM Joachim Protze via discuss <<a href="mailto:discuss@mpich.org">discuss@mpich.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Bruce,<br>
<br>
I think, you could use the keyval and set/get-attr functions for that <br>
purpose and it should even be portable :)<br>
Without testing the code, I would so something like the following:<br>
<br>
<br>
#define S1(x) #x<br>
#define S2(x) S1(x)<br>
#define LOCATION __FILE__ " : " S2(__LINE__)<br>
int win_debug_string_key;<br>
const int max_win_debug_string_len = 30;<br>
<br>
int My_copy_attr_function(<br>
   MPI_Win oldwin, int win_keyval,<br>
   void *extra_state, void *attribute_val_in,<br>
   void *attribute_val_out, int *flag)<br>
{<br>
   attribute_val_out = strndup(attribute_val_in, *(int*)extra_state);<br>
   flag = 1; /* or set 0 if a copy is intended to be different */<br>
}<br>
<br>
int My_delete_attr_function(<br>
   MPI_Win win, int win_keyval,<br>
   void *attribute_val, void *extra_state)<br>
{<br>
   free(attribute_val);<br>
}<br>
<br>
<br>
<br>
/* Define the keyval once */<br>
MPI_Win_create_keyval( My_copy_attr_function, My_delete_attr_function, <br>
&win_debug_string_key, &max_win_debug_string_len );<br>
<br>
<br>
/* When creating a window */<br>
MPI_Win_create( ..., &win );<br>
<br>
/* be aware of the extra byte for the \0 byte */<br>
char * win_debug_string = malloc(sizeof(char)*(max_win_debug_string_len+1));<br>
/* Write the current location in there: */<br>
strncpy(win_debug_string, LOCATION);<br>
/* Bind the debug-string to the new window */<br>
MPI_Win_set_attr( win, win_debug_string_key, win_debug_string );<br>
<br>
<br>
Best<br>
Joachim<br>
<br>
<br>
On 4/18/19 12:32 AM, Palmer, Bruce J via discuss wrote:<br>
> Hi,<br>
> <br>
> Strictly for debugging purposes, is there a way in MPICH to determine if <br>
> a MPI_Win created at point A in a code is the same window being accessed <br>
> at point B? It doesn’t need to be portable, I’m just interested in using <br>
> it to fix some bugs (that are probably not associated with MPI).<br>
> <br>
> Bruce Palmer<br>
> <br>
> Computer Scientist<br>
> <br>
> Pacific Northwest National Laboratory<br>
> <br>
> (509) 375-3899<br>
> <br>
> <br>
> _______________________________________________<br>
> discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mpich.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
> <br>
<br>
<br>
-- <br>
Dipl.-Inf. Joachim Protze<br>
<br>
IT Center<br>
Group: High Performance Computing<br>
Division: Computational Science and Engineering<br>
RWTH Aachen University<br>
Seffenter Weg 23<br>
D 52074  Aachen (Germany)<br>
Tel: +49 241 80- 24765<br>
Fax: +49 241 80-624765<br>
<a href="mailto:protze@itc.rwth-aachen.de" target="_blank">protze@itc.rwth-aachen.de</a><br>
<a href="http://www.itc.rwth-aachen.de" rel="noreferrer" target="_blank">www.itc.rwth-aachen.de</a><br>
<br>
_______________________________________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>