MPICH-GM and Intel 7.x compilers

Patrick Geoffray <[email protected]> 01 May 2003 17:16:22 -0400
Newsgroups gmane.network.myrinet.general
Message-ID <1051823784.556.166.camel@asterix>
Folks,

We have found what we believe was the root cause of the problems related
to MPICH-GM and Intel 7.x compilers on IA-64.

Attached is a small piece of code that exhibits a compiler bug when
compiled with -O or -O2 on IA64 (fine with -O1 and on IA32). A bug
report has been filed with Intel. This code is basically in the malloc
code that MPICH-GM uses, which is ptmalloc (the malloc of glibc-2).

We have been able to work around it and MPICH-GM 1.2.5..10 is ready to
roll out (announcement will be posted in the list shortly). So far, all
of the applications that failed with Intel 7/x on IA64 with 1.2.5..9 are
working fine with 1.2.5..10 (for example HPL with MKL lib).

Patrick
-- 

Patrick Geoffray, PhD
Myricom, Inc.
http://www.myri.com
bug.c (text/x-c, 1.3 KB)
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>

struct malloc_chunk {
  int      prev_size;
  int      size;

  struct malloc_chunk* fd;
  struct malloc_chunk* bk;
};

struct malloc_chunk *list1;
struct malloc_chunk *list2;
struct malloc_chunk junk;

void buggy();

main()
{
  struct malloc_chunk *       p;
    struct malloc_chunk c1;
    struct malloc_chunk c3;

    c1.fd = &c1;
    c1.bk = &c1;
    list1 = &c1;

    c3.fd = 0;
    c3.bk = 0;
    list2 = &c3;

    buggy();

   if (c3.fd == &c3)
	printf("BUGBUGBUG\n");
   else if (c3.fd == &c1)
	printf("OK\n");
   else
	printf("something is weird\n");
}

    
/*
 * This routine should just traverse list2 put those 
 * elements on list1.  When optimized, list1 ends up messed up
 */
void
buggy()
{
  struct malloc_chunk *p;
  struct malloc_chunk *nextp;
  struct malloc_chunk *my_list1;
  struct malloc_chunk *list1_top;

    my_list1 = list1;

    do {
      p = list2;

        do {
          nextp = p->fd;

	    p->size = 1;

            list1_top = my_list1->fd;
            my_list1->fd = p;
            list1_top->bk = p;
            
            p->bk = my_list1;
            p->fd = list1_top;

        } while ( (p = nextp) != 0);

    } while (my_list1++ == 0);  /* required for bug, doesn't do anything */
			        /* even the "++" is important */
}