openmpi  3.1.6
About: Open MPI is a high performance Message Passing Interface (MPI) library project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to build the best MPI library available. 3.x series.
  Fossies Dox: openmpi-3.1.6.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

opal_pointer_array.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  * University Research and Technology
5  * Corporation. All rights reserved.
6  * Copyright (c) 2004-2017 The University of Tennessee and The University
7  * of Tennessee Research Foundation. All rights
8  * reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  * University of Stuttgart. All rights reserved.
11  * Copyright (c) 2004-2005 The Regents of the University of California.
12  * All rights reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  */
29 #ifndef OPAL_POINTER_ARRAY_H
30 #define OPAL_POINTER_ARRAY_H
31 
32 #include "opal_config.h"
33 
34 #include "opal/threads/mutex.h"
35 #include "opal/class/opal_object.h"
36 #include "opal/prefetch.h"
37 
39 
56  int size;
58  int max_size;
62  uint64_t* free_bits;
64  void **addr;
65 };
74 
90  int initial_allocation,
91  int max_size, int block_size );
92 
103 
114  int index, void *value);
115 
126  int element_index)
127 {
128  void *p;
129 
130  if( OPAL_UNLIKELY(0 > element_index || table->size <= element_index) ) {
131  return NULL;
132  }
133  OPAL_THREAD_LOCK(&(table->lock));
134  p = table->addr[element_index];
135  OPAL_THREAD_UNLOCK(&(table->lock));
136  return p;
137 }
138 
139 
151 {
152  return array->size;
153 }
154 
166 
182  int index,
183  void *value);
184 
192 {
193  int i;
194  if( array->number_free == array->size )
195  return; /* nothing to do here this time (the array is already empty) */
196 
197  OPAL_THREAD_LOCK(&array->lock);
198  array->lowest_free = 0;
199  array->number_free = array->size;
200  for(i = 0; i < array->size; i++) {
201  array->addr[i] = NULL;
202  }
203  for(i = 0; i < (int)((array->size + 8*sizeof(uint64_t) - 1) / (8*sizeof(uint64_t))); i++) {
204  array->free_bits[i] = 0;
205  }
206  OPAL_THREAD_UNLOCK(&array->lock);
207 }
208 
210 
211 #endif /* OPAL_POINTER_ARRAY_H */
opal_pointer_array_set_size
OPAL_DECLSPEC int opal_pointer_array_set_size(opal_pointer_array_t *array, int size)
Set the size of the pointer array.
Definition: opal_pointer_array.c:400
opal_pointer_array_t::number_free
int number_free
number of free elements in the list
Definition: opal_pointer_array.h:54
prefetch.h
opal_pointer_array_remove_all
static void opal_pointer_array_remove_all(opal_pointer_array_t *array)
Empty the array.
Definition: opal_pointer_array.h:191
mutex.h
opal_pointer_array_t::max_size
int max_size
maximum size of the array
Definition: opal_pointer_array.h:58
BEGIN_C_DECLS
#define BEGIN_C_DECLS
code that should be in ompi_config_bottom.h regardless of build status
Definition: opal_config_bottom.h:85
OPAL_UNLIKELY
#define OPAL_UNLIKELY(expression)
Definition: prefetch.h:47
opal_pointer_array_init
OPAL_DECLSPEC int opal_pointer_array_init(opal_pointer_array_t *array, int initial_allocation, int max_size, int block_size)
Initialize the pointer array with an initial size of initial_allocation.
Definition: opal_pointer_array.c:178
opal_object_t
Base object.
Definition: opal_object.h:194
OBJ_CLASS_DECLARATION
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_pointer_array_t)
Class declaration.
opal_object.h
value
#define value
Definition: btl_openib_lex.c:606
opal_mutex_t
Definition: mutex_unix.h:49
opal_pointer_array_set_item
OPAL_DECLSPEC int opal_pointer_array_set_item(opal_pointer_array_t *array, int index, void *value)
Set the value of an element in array.
Definition: opal_pointer_array.c:271
opal_pointer_array_get_size
static int opal_pointer_array_get_size(opal_pointer_array_t *array)
Get the size of the pointer array.
Definition: opal_pointer_array.h:150
opal_pointer_array_t::lock
opal_mutex_t lock
synchronization object
Definition: opal_pointer_array.h:47
OPAL_DECLSPEC
#define OPAL_DECLSPEC
Definition: opal_config_bottom.h:253
opal_pointer_array_t::free_bits
uint64_t * free_bits
pointer to an array of bits to speed up the research for an empty position.
Definition: opal_pointer_array.h:62
OPAL_THREAD_UNLOCK
#define OPAL_THREAD_UNLOCK(mutex)
Unlock a mutex if opal_using_threads() says that multiple threads may be active in the process.
Definition: mutex.h:156
opal_pointer_array_add
OPAL_DECLSPEC int opal_pointer_array_add(opal_pointer_array_t *array, void *ptr)
Add a pointer to the array (Grow the array, if need be)
Definition: opal_pointer_array.c:220
opal_pointer_array_t
dynamic pointer array
Definition: opal_pointer_array.h:43
opal_pointer_array_get_item
static void * opal_pointer_array_get_item(opal_pointer_array_t *table, int element_index)
Get the value of an element in array.
Definition: opal_pointer_array.h:125
opal_pointer_array_t::size
int size
size of list, i.e.
Definition: opal_pointer_array.h:56
opal_pointer_array_t::super
opal_object_t super
base class
Definition: opal_pointer_array.h:45
opal_pointer_array_t::lowest_free
int lowest_free
Index of lowest free element.
Definition: opal_pointer_array.h:52
opal_pointer_array_test_and_set_item
OPAL_DECLSPEC bool opal_pointer_array_test_and_set_item(opal_pointer_array_t *table, int index, void *value)
Test whether a certain element is already in use.
Definition: opal_pointer_array.c:340
opal_pointer_array_t::addr
void ** addr
pointer to array of pointers
Definition: opal_pointer_array.h:64
END_C_DECLS
#define END_C_DECLS
Definition: opal_config_bottom.h:86
OPAL_THREAD_LOCK
#define OPAL_THREAD_LOCK(mutex)
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process.
Definition: mutex.h:117
NULL
#define NULL
Copyright (C) 2000-2004 by Etnus, LLC.
Definition: ompi_msgq_dll.c:136
opal_pointer_array_t::block_size
int block_size
block size for each allocation
Definition: opal_pointer_array.h:60