Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] 1.4.4rc2 is up
From: Larry Baker (baker_at_[hidden])
Date: 2011-05-20 18:32:58


Jeff,

I get warnings from all my compilers running "make check" when
compiling test/class/ompi_rb_tree.c. For example, using gcc/g++/
gfortran:

> ompi_rb_tree.c: In function 'test2':
> ompi_rb_tree.c:347: warning: cast to pointer from integer of
> different size
> ompi_rb_tree.c:365: warning: cast from pointer to integer of
> different size
> ompi_rb_tree.c:373: warning: cast from pointer to integer of
> different size

This is due, I am sure, to the mixing of 64-bit pointers and 32-bit
integers. Do you have a "safe" method to do these conversions so
these warnings go away? Maybe a macro you use in the library?

While looking at the source of the warnings, I saw that the code in
test/class/ompi_rb_tree.c, lines 361-368 are duplicated in lines
369-376 (quoted, below). Is this intentional?

Larry Baker
US Geological Survey
650-329-5608
baker_at_[hidden]

function test2() in test/class/ompi_rb_tree.c:

void test2(void)
{
     ompi_free_list_t key_list;
     ompi_free_list_item_t * new_value;
     ompi_rb_tree_t tree;
     int rc, i, size;
     void * result, * lookup;
     void * mem[NUM_ALLOCATIONS];
     ompi_free_list_item_t * key_array[NUM_ALLOCATIONS];
     struct timeval start, end;

     OBJ_CONSTRUCT(&key_list, ompi_free_list_t);
     ompi_free_list_init_new(&key_list, sizeof(ompi_test_rb_value_t),
             CACHE_LINE_SIZE,
             OBJ_CLASS(ompi_test_rb_value_t),
             0,CACHE_LINE_SIZE,
             0, -1 , 128, NULL);

     OBJ_CONSTRUCT(&tree, ompi_rb_tree_t);
     rc = ompi_rb_tree_init(&tree, mem_node_compare);
     if(!test_verify_int(OMPI_SUCCESS, rc)) {
         test_failure("failed to properly initialize the tree");
     }

     size = 1;
     for(i = 0; i < NUM_ALLOCATIONS; i++)
     {
         mem[i] = malloc(size);
         if(NULL == mem[i])
         {
             test_failure("system out of memory");
             return;
         }
         OMPI_FREE_LIST_GET(&key_list, new_value, rc);
         if(OMPI_SUCCESS != rc)
         {
             test_failure("failed to get memory from free list");
         }
         key_array[i] = new_value;
         ((ompi_test_rb_value_t *) new_value)->key.bottom = mem[i];
         ((ompi_test_rb_value_t *) new_value)->key.top =
                                             (void *) ((size_t) mem[i]
+ size - 1);
         ((ompi_test_rb_value_t *) new_value)->registered_mpools[0] =
(void *) i;
         rc = ompi_rb_tree_insert(&tree, &((ompi_test_rb_value_t
*)new_value)->key,
                         new_value);
         if(OMPI_SUCCESS != rc)
         {
             test_failure("failed to properly insert a new node");
         }
         size += 1;
     }

     gettimeofday(&start, NULL);
     for(i = 0; i < NUM_ALLOCATIONS; i++)
     {
         lookup = (void *) ((size_t) mem[i] + i);
         result = ompi_rb_tree_find(&tree, &lookup);
         if(NULL == result)
         {
             test_failure("lookup returned null!");
         } else if(i != ((int) ((ompi_test_rb_value_t *) result)-
>registered_mpools[0]))
         {
             test_failure("lookup returned wrong node!");
         }
> result = ompi_rb_tree_find(&tree, &lookup);
> if(NULL == result)
> {
> test_failure("lookup returned null!");
> } else if(i != ((int) ((ompi_test_rb_value_t *) result)-
> >registered_mpools[0]))
> {
> test_failure("lookup returned wrong node!");
> }
     }

     gettimeofday(&end, NULL);

#if 0
     i = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec -
start.tv_usec);
     printf("In a %d node tree, %d lookups took %f microseonds each\n",
             NUM_ALLOCATIONS, NUM_ALLOCATIONS * 2,
             (float) i / (float) (NUM_ALLOCATIONS * 2));
#endif

     for(i = 0; i < NUM_ALLOCATIONS; i++)
     {
         if(NULL != mem[i])
         {
             free(mem[i]);
         }
         OMPI_FREE_LIST_RETURN(&(key_list), key_array[i]);
     }

     OBJ_DESTRUCT(&tree);
     OBJ_DESTRUCT(&key_list);
}

On 5 May 2011, at 7:15 AM, Jeff Squyres wrote:

> Fixed the ROMIO attribute problem properly this time -- it's in the
> usual place:
>
> http://www.open-mpi.org/software/ompi/v1.4/
>
> --
> Jeff Squyres
> jsquyres_at_[hidden]
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel