Skip to content

Commit fe17410

Browse files
committed
next step in making the print_queue functionality move to common/ompio
1 parent af67c8f commit fe17410

File tree

7 files changed

+125
-464
lines changed

7 files changed

+125
-464
lines changed

ompi/mca/common/ompio/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#
2020

2121
headers = \
22-
common_ompio_print_queue.h
22+
common_ompio_print_queue.h \
23+
common_ompio.h
2324

2425
sources = \
2526
common_ompio_print_queue.c
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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-2007 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 (c) 2008-2016 University of Houston. All rights reserved.
14+
* $COPYRIGHT$
15+
*
16+
* Additional copyrights may follow
17+
*
18+
* $HEADER$
19+
*/
20+
21+
#ifndef MCA_COMMON_OMPIO_H
22+
#define MCA_COMMON_OMPIO_H
23+
24+
#include "ompi/mca/common/ompio/common_ompio_print_queue.h"
25+
#include "ompi/mca/io/ompio/io_ompio.h"
26+
27+
#endif /* MCA_COMMON_OMPIO_H */

ompi/mca/common/ompio/common_ompio_print_queue.c

Lines changed: 59 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
14-
* Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved.
15-
* Copyright (c) 2012-2013 Inria. All rights reserved.
16-
* Copyright (c) 2015 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
14+
*
1815
* $COPYRIGHT$
1916
*
2017
* Additional copyrights may follow
@@ -27,139 +24,88 @@
2724
#include "ompi/communicator/communicator.h"
2825
#include "ompi/datatype/ompi_datatype.h"
2926

30-
#include "common_ompio_print_queue.h"
27+
#include "ompi/mca/common/ompio/common_ompio.h"
3128

32-
mca_common_ompio_print_queue *coll_write_time=NULL;
33-
mca_common_ompio_print_queue *coll_read_time=NULL;
3429

3530
/* Print queue related function implementations */
36-
int common_ompio_set_print_queue (mca_common_ompio_print_queue **q,
37-
int queue_type){
38-
39-
int ret = OMPI_SUCCESS;
40-
41-
switch(queue_type) {
42-
43-
case WRITE_PRINT_QUEUE:
44-
*q = coll_write_time;
45-
break;
46-
case READ_PRINT_QUEUE:
47-
*q = coll_read_time;
48-
break;
49-
}
50-
51-
if (NULL == q){
52-
ret = OMPI_ERROR;
53-
}
54-
return ret;
55-
56-
}
57-
31+
int mca_common_ompio_initialize_print_queue( mca_common_ompio_print_queue **r){
5832

59-
int common_ompio_initialize_print_queue(void *r){
60-
61-
mca_common_ompio_print_queue *q;
33+
mca_common_ompio_print_queue *q=NULL;
6234
int ret = OMPI_SUCCESS;
6335

6436
q = (mca_common_ompio_print_queue *) malloc ( sizeof(mca_common_ompio_print_queue));
6537
if ( NULL == q ) {
6638
ret = OMPI_ERR_OUT_OF_RESOURCE;
6739
}
6840
q->first = 0;
69-
q->last = COMMON_OMPIO_QUEUESIZE - 1;
41+
q->last = MCA_COMMON_OMPIO_QUEUESIZE - 1;
7042
q->count = 0;
7143

72-
*r = ( void *) *q;
44+
*r = q;
7345
return ret;
7446
}
75-
int common_ompio_register_print_entry (int queue_type,
76-
mca_common_ompio_print_entry x){
7747

78-
int ret = OMPI_SUCCESS;
79-
mca_common_ompio_print_queue *q=NULL;
80-
81-
ret = common_ompio_set_print_queue(&q, queue_type);
82-
83-
if (ret != OMPI_ERROR){
84-
if (q->count >= COMMON_OMPIO_QUEUESIZE){
85-
return OMPI_ERROR;
86-
}
87-
else{
88-
q->last = (q->last + 1) % COMMON_OMPIO_QUEUESIZE;
89-
q->entry[q->last] = x;
90-
q->count = q->count + 1;
91-
}
48+
int mca_common_ompio_register_print_entry ( mca_common_ompio_print_queue *q,
49+
mca_common_ompio_print_entry x)
50+
{
51+
if (q->count >= MCA_COMMON_OMPIO_QUEUESIZE){
52+
return OMPI_ERROR;
9253
}
93-
return ret;
94-
}
95-
96-
int common_ompio_unregister_print_entry (int queue_type,
97-
mca_common_ompio_print_entry *x){
98-
99-
int ret = OMPI_SUCCESS;
100-
mca_common_ompio_print_queue *q=NULL;
101-
ret = common_ompio_set_print_queue(&q, queue_type);
102-
if (ret != OMPI_ERROR){
103-
if (q->count <= 0){
104-
return OMPI_ERROR;
105-
}
106-
else{
107-
*x = q->entry[q->first];
108-
q->first = (q->first+1) % COMMON_OMPIO_QUEUESIZE;
109-
q->count = q->count - 1;
110-
}
54+
else{
55+
q->last = (q->last + 1) % MCA_COMMON_OMPIO_QUEUESIZE;
56+
q->entry[q->last] = x;
57+
q->count = q->count + 1;
11158
}
59+
11260
return OMPI_SUCCESS;
11361
}
11462

115-
int common_ompio_empty_print_queue(int queue_type){
116-
117-
int ret = OMPI_SUCCESS;
118-
mca_common_ompio_print_queue *q=NULL;
119-
ret = common_ompio_set_print_queue(&q, queue_type);
120-
121-
assert (ret != OMPI_ERROR);
122-
(void)ret; // silence compiler warning
123-
if (q->count == 0)
124-
return 1;
125-
else
126-
return 0;
63+
int mca_common_ompio_unregister_print_entry ( mca_common_ompio_print_queue *q,
64+
mca_common_ompio_print_entry *x)
65+
{
12766

67+
if (q->count <= 0){
68+
return OMPI_ERROR;
69+
}
70+
else{
71+
*x = q->entry[q->first];
72+
q->first = (q->first+1) % MCA_COMMON_OMPIO_QUEUESIZE;
73+
q->count = q->count - 1;
74+
}
12875

76+
return OMPI_SUCCESS;
12977
}
13078

131-
int common_ompio_full_print_queue(int queue_type){
132-
133-
134-
int ret = OMPI_SUCCESS;
135-
mca_common_ompio_print_queue *q=NULL;
136-
ret = common_ompio_set_print_queue(&q, queue_type);
79+
int mca_common_ompio_empty_print_queue(mca_common_ompio_print_queue *q)
80+
{
81+
if (q->count == 0) {
82+
return 1;
83+
}
84+
85+
return 0;
86+
}
13787

138-
assert ( ret != OMPI_ERROR);
139-
(void)ret; // silence compiler warning
140-
if (q->count < COMMON_OMPIO_QUEUESIZE)
141-
return 0;
142-
else
143-
return 1;
88+
int mca_common_ompio_full_print_queue(mca_common_ompio_print_queue *q)
89+
{
90+
if (q->count < MCA_COMMON_OMPIO_QUEUESIZE) {
91+
return 0;
92+
}
14493

94+
return 1;
14595
}
14696

14797

148-
int common_ompio_print_time_info(int queue_type,
149-
char *name,
150-
mca_io_ompio_file_t *fh){
98+
int mca_common_ompio_print_time_info( mca_common_ompio_print_queue *q,
99+
char *name,
100+
struct mca_io_ompio_file_t *fh){
151101

152102
int i = 0, j=0, nprocs_for_coll = 0, ret = OMPI_SUCCESS, count = 0;
153103
double *time_details = NULL, *final_sum = NULL;
154104
double *final_max = NULL, *final_min = NULL;
155105
double *final_time_details=NULL;
156-
mca_common_ompio_print_queue *q=NULL;
157-
158-
ret = common_ompio_set_print_queue(&q, queue_type);
159106

160-
assert (ret != OMPI_ERROR);
161107
nprocs_for_coll = q->entry[0].nprocs_for_coll;
162-
time_details = (double *) malloc (4*sizeof(double));
108+
time_details = (double *) calloc (4,sizeof(double));
163109
if ( NULL == time_details){
164110
ret = OMPI_ERR_OUT_OF_RESOURCE;
165111
goto exit;
@@ -187,24 +133,13 @@ int common_ompio_print_time_info(int queue_type,
187133
goto exit;
188134
}
189135

190-
final_time_details =
191-
(double *)malloc
192-
(fh->f_size * 4 * sizeof(double));
136+
final_time_details = (double *)calloc (fh->f_size, 4 * sizeof(double));
193137
if (NULL == final_time_details){
194138
ret = OMPI_ERR_OUT_OF_RESOURCE;
195139
goto exit;
196140
}
197141

198142
count = 4 * fh->f_size;
199-
for(i=0;i<count;i++){
200-
final_time_details[i] = 0.0;
201-
}
202-
203-
204-
}
205-
206-
for (i = 0; i < 4; i++){
207-
time_details[i] = 0.0;
208143
}
209144

210145
if (q->count > 0){
@@ -221,17 +156,18 @@ int common_ompio_print_time_info(int queue_type,
221156
}
222157
}
223158

224-
fh->f_comm->c_coll.coll_gather(time_details,
225-
4,
226-
MPI_DOUBLE,
227-
final_time_details,
228-
4,
229-
MPI_DOUBLE,
230-
0,
231-
fh->f_comm,
232-
fh->f_comm->c_coll.coll_gather_module);
233-
234-
159+
ret = fh->f_comm->c_coll.coll_gather(time_details,
160+
4,
161+
MPI_DOUBLE,
162+
final_time_details,
163+
4,
164+
MPI_DOUBLE,
165+
0,
166+
fh->f_comm,
167+
fh->f_comm->c_coll.coll_gather_module);
168+
169+
if ( OMPI_SUCCESS != ret ) {
170+
}
235171

236172
if (!fh->f_rank){
237173

ompi/mca/common/ompio/common_ompio_print_queue.h

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@
2525

2626

2727
#include "mpi.h"
28-
#include "ompi/mca/io/ompio/io_ompio.h"
2928

3029
OMPI_DECLSPEC extern int mca_io_ompio_coll_timing_info;
30+
struct mca_io_ompio_file_t;
3131

32-
#define COMMON_OMPIO_QUEUESIZE 2048
33-
34-
/* PRINT QUEUES*/
35-
#define WRITE_PRINT_QUEUE 1809
36-
#define READ_PRINT_QUEUE 2178
37-
/*---------------------------*/
32+
#define MCA_COMMON_OMPIO_QUEUESIZE 2048
3833

3934
/*To extract time-information */
4035
typedef struct {
@@ -44,34 +39,27 @@ typedef struct {
4439
}mca_common_ompio_print_entry;
4540

4641
typedef struct {
47-
mca_common_ompio_print_entry entry[COMMON_OMPIO_QUEUESIZE + 1];
42+
mca_common_ompio_print_entry entry[MCA_COMMON_OMPIO_QUEUESIZE + 1];
4843
int first;
4944
int last;
5045
int count;
5146
} mca_common_ompio_print_queue;
5247

5348

54-
OMPI_DECLSPEC extern mca_common_ompio_print_queue *coll_write_time;
55-
OMPI_DECLSPEC extern mca_common_ompio_print_queue *coll_read_time;
56-
57-
58-
OMPI_DECLSPEC int common_ompio_register_print_entry (int queue_type,
59-
mca_common_ompio_print_entry x);
49+
OMPI_DECLSPEC int mca_common_ompio_register_print_entry (mca_common_ompio_print_queue *q,
50+
mca_common_ompio_print_entry x);
6051

61-
OMPI_DECLSPEC int common_ompio_unregister_print_entry (int queue_type,
62-
mca_common_ompio_print_entry *x);
52+
OMPI_DECLSPEC int mca_common_ompio_unregister_print_entry (mca_common_ompio_print_queue *q,
53+
mca_common_ompio_print_entry *x);
6354

64-
OMPI_DECLSPEC int common_ompio_empty_print_queue(int queue_type);
55+
OMPI_DECLSPEC int mca_common_ompio_empty_print_queue(mca_common_ompio_print_queue *q);
6556

66-
OMPI_DECLSPEC int common_ompio_full_print_queue(int queue_type);
57+
OMPI_DECLSPEC int mca_common_ompio_full_print_queue(mca_common_ompio_print_queue *q);
6758

68-
OMPI_DECLSPEC int common_ompio_initialize_print_queue(mca_common_ompio_print_queue *q);
59+
OMPI_DECLSPEC int mca_common_ompio_initialize_print_queue(mca_common_ompio_print_queue **q);
6960

70-
OMPI_DECLSPEC int common_ompio_print_time_info(int queue_type,
71-
char *name_operation,
72-
mca_io_ompio_file_t *fh);
73-
int common_ompio_set_print_queue (mca_common_ompio_print_queue **q,
74-
int queue_type);
61+
OMPI_DECLSPEC int mca_common_ompio_print_time_info( mca_common_ompio_print_queue *q,
62+
char *name_operation, struct mca_io_ompio_file_t *fh);
7563

7664

7765
END_C_DECLS

0 commit comments

Comments
 (0)