OpenMPI  0.1.1
mtl_portals_send_short.h
1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2006 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * $COPYRIGHT$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 
19 #ifndef OMPI_MTL_PORTALS_SEND_SHORT_H
20 #define OMPI_MTL_PORTALS_SEND_SHORT_H
21 
22 extern void ompi_mtl_portals_short_setup(void);
23 extern void ompi_mtl_portals_short_cleanup(void);
24 
25 static inline int
26 ompi_mtl_portals_alloc_short_buf(void)
27 {
28  int buf_num;
29 
30  while ( ompi_mtl_portals.ptl_copy_block_first_free == ompi_mtl_portals.ptl_num_copy_blocks ) {
31  ompi_mtl_portals_progress();
32  }
33 
34  buf_num = ompi_mtl_portals.ptl_copy_block_free_list[ompi_mtl_portals.ptl_copy_block_first_free++];
35 
36  assert((buf_num >= 0) && (buf_num < ompi_mtl_portals.ptl_num_copy_blocks));
37 
38  return buf_num;
39 }
40 
41 static inline void
42 ompi_mtl_portals_free_short_buf( int offset )
43 {
44  int buf_num;
45 
46  buf_num = offset / ompi_mtl_portals.ptl_copy_block_len;
47 
48  assert((buf_num >= 0) && (buf_num < ompi_mtl_portals.ptl_num_copy_blocks));
49 
50  ompi_mtl_portals.ptl_copy_block_first_free--;
51 
52  assert(ompi_mtl_portals.ptl_copy_block_first_free >= 0);
53 
54  ompi_mtl_portals.ptl_copy_block_free_list[ompi_mtl_portals.ptl_copy_block_first_free] = buf_num;
55 
56 }
57 
58 
59 #endif /* OMPI_MTL_PORTALS_SEND_SHORT_H */