Changeset 64


Ignore:
Timestamp:
04/27/10 12:14:45 (3 years ago)
Author:
faltet
Message:

Added new blosc_free_resources() function to release resources in Blosc.

Location:
branches/threaded/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/threaded/src/bench.c

    r63 r64  
    141141  int fd; 
    142142  int status; 
    143   unsigned int size = 128*1024;   /* Buffer size */ 
     143  unsigned int size = 256*1024;   /* Buffer size */ 
    144144  unsigned int elsize = 8;        /* Datatype size */ 
    145145  int rshift = 12;                /* For random data */ 
    146   int nthreads = 1;               /* The number of threads */ 
     146  int nthreads = 4;               /* The number of threads */ 
    147147  int doshuffle = 1;              /* Shuffle? */ 
    148148  unsigned char *orig, *round; 
     
    260260    free(dest[i]); 
    261261  } 
     262 
     263  /* Free blosc resources */ 
     264  blosc_free_resources(); 
     265 
    262266  return 0; 
    263267} 
  • branches/threaded/src/blosc.c

    r63 r64  
    842842} 
    843843 
     844 
     845/* Free possible memory temporaries and thread resources */ 
     846void 
     847blosc_free_resources(void) 
     848{ 
     849  int t, rc; 
     850  void *status; 
     851 
     852  /* Release temporaries */ 
     853  if (init_temps_done) { 
     854    release_temporaries(); 
     855  } 
     856 
     857  /* Finish the possible thread pool */ 
     858  if (nthreads > 1 && init_threads_done) { 
     859    /* Tell all existing threads to end */ 
     860    end_threads = 1; 
     861    rc = pthread_barrier_wait(&barr_init); 
     862    if (rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD) { 
     863      exit(-1); 
     864    } 
     865    /* Join exiting threads */ 
     866    for (t=0; t<nthreads; t++) { 
     867      rc = pthread_join(threads[t], &status); 
     868      if (rc) { 
     869        fprintf(stderr, "ERROR; return code from pthread_join() is %d\n", rc); 
     870        fprintf(stderr, "\tError detail: %s\n", strerror(rc)); 
     871        exit(-1); 
     872      } 
     873    } 
     874 
     875    /* Release mutex and condition variable objects */ 
     876    pthread_mutex_destroy(&count_mutex); 
     877 
     878    /* Barriers */ 
     879    pthread_barrier_destroy(&barr_init); 
     880    pthread_barrier_destroy(&barr_inter); 
     881    pthread_barrier_destroy(&barr_finish); 
     882 
     883    /* Thread attributes */ 
     884    pthread_attr_destroy(&ct_attr); 
     885 
     886    init_threads_done = 0; 
     887    end_threads = 0; 
     888  } 
     889} 
  • branches/threaded/src/blosc.h

    r60 r64  
    2929/** 
    3030 
    31    Initialize a pool of threads for compression/decompression.  If 
    32    `nthreads` is 1, then the serial version is chosen and a possible 
    33    previous existing pool is ended.  Returns the previous number of 
    34    threads. 
     31  Initialize a pool of threads for compression/decompression.  If 
     32  `nthreads` is 1, then the serial version is chosen and a possible 
     33  previous existing pool is ended.  Returns the previous number of 
     34  threads. 
    3535 
    3636*/ 
     
    9797blosc_decompress(const void *src, void *dest, size_t dest_size); 
    9898 
     99 
     100/** 
     101 
     102  Free possible memory temporaries and thread resources.  Use this 
     103  when you are not going to use Blosc for a long while. 
     104 
     105*/ 
     106 
     107void 
     108blosc_free_resources(void); 
     109 
    99110#endif 
Note: See TracChangeset for help on using the changeset viewer.