Thread: Error with Hoard but not with libc.so.6

  1. #1
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665

    Error with Hoard but not with libc.so.6

    Hello All,

    I have an interesting sort of error that I'm not sure how to fix.

    First, the problem at hand is that I'm getting uninitialized value errors when using two threads with Hoard but when I use the standard malloc, I don't get any such errors. Also, the errors cause me to leak while the standard malloc de-allocates fine.

    We have a particle structure :
    Code:
    struct particle {
    
        long double x;
        long double y;
        long double z;
    };
    And we allocate in the main-loop with :
    Code:
    struct particle *p = malloc(512*sizeof(*p));
    
    for (int x=0; x<8; x++) {
       for (int y=0; y<8; y++) {
          for (int z=0; z<8; z++) {
    
    
              p[x*64+y*8+z].x = x;
              p[x*64+y*8+z].y = y;
              p[x*64+y*8+z].z = z;
           }
        }
    }
    But because pthreads are really lame in the way that they only really want a void pointer, I had to declare a threading structure because I need to pass as arguments a pointer to a location in a quadtree and a pointer to a particle from our p pointer, in my case &p[73] is the address.

    So, we have :
    Code:
    struct thread {
    
       struct branch *b;
       struct particle *p;
    };
    
    void* shear(void *t) {
    
    
       struct thread *thr = t;
    
    
       search(thr->b, thr->p);
    
    
       return NULL;
    }
    
    
    struct thread* buildCell(struct branch *b, struct particle *p) {
    
    
       struct thread *t = malloc(sizeof(*t));
    
    
       t->b = b;
       t->p = p;
    
    
       return t;
    }
    and in my main loop, I have :
    Code:
       pthread_t shears[2];
    
    
       struct thread *thr1 = buildCell(root->children[0], &p[73]);
       struct thread *thr2 = buildCell(root->children[2], &p[73]);
    
    
       pthread_create(&shears[0], NULL, shear, thr1);
       pthread_create(&shears[1], NULL, shear, thr2);
    
    
       pthread_join(shears[0], NULL);
       pthread_join(shears[1], NULL);
    
    
       free(thr1);
       free(thr2);
    root is the root of the quadtree and yes, it has children. It has 4 children at the time p[73] is to be added. And shear is our thread function and thr1 and 2 are the arguments required for search'ing the tree which is a separate function which probes the entire tree given certain conditions, i.e. is the particle within the 'bounding box' or not which is a form of checking for shared edges.

    The Hoard errors tell me that my malloc of p yields initialized values but I don't see how considering the standard malloc works fine. Is this is a shortcoming in Hoard?

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Nevermind, I even tried tcmalloc. Apparently, these non-standard libraries are just awful. So forget that noise, I'ma deal with that stuff way later.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. /usr/bin/ld: errno: TLS definition in /lib/libc.so.6
    By nasim751 in forum C Programming
    Replies: 4
    Last Post: 02-25-2009, 04:15 AM
  2. Linking Error (libc.lib)
    By gpr1me in forum Game Programming
    Replies: 0
    Last Post: 03-30-2006, 01:28 PM
  3. How do you exclude libc using gcc?
    By ShortCoder in forum C Programming
    Replies: 7
    Last Post: 05-22-2004, 09:39 AM
  4. jpeg.lib confilicting with libc
    By glUser3f in forum C++ Programming
    Replies: 4
    Last Post: 09-24-2003, 02:16 PM
  5. Those lucky SPAM hoard recipients
    By lightatdawn in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 10-29-2002, 10:05 AM