MPQC 2.3.1
messshm.h
1//
2// messshm.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _util_group_messshm_h
29#define _util_group_messshm_h
30
31#include <unistd.h>
32#include <sys/types.h>
33#include <sys/ipc.h>
34#include <sys/sem.h>
35#include <sys/shm.h>
36
37#include <util/group/message.h>
38
39namespace sc {
40
41#define SHMCOMMBUFSIZE 1500000
42
43/* Set the maximum number of processors (including the host). */
44#define MAXPROCS 17
45
46
48 int nmsg;
49 int n_wait_for_change;
50 int n_sync;
51 char buf[SHMCOMMBUFSIZE];
52};
53typedef struct commbuf_struct commbuf_t;
54
56 int type;
57 int from;
58 int size;
59};
60typedef struct msgbuf_struct msgbuf_t;
61
69 protected:
70 void basic_send(int target, int type, const void* data, int nbyte);
71 void basic_recv(int type, void* data, int nbyte);
72 int basic_probe(int type);
73 void initialize(int nprocs);
74 void initialize();
75
76 // previously static variables
77 commbuf_t *commbuf[MAXPROCS];
78 int shmid;
79 int semid;
80 int change_semid;
81 void* sharedmem;
82 struct sembuf semdec;
83 struct sembuf seminc;
84
85 // previously static functions for semephore operations
86 msgbuf_t *NEXT_MESSAGE(msgbuf_t *m);
87 void get_change(int node);
88 void put_change(int node);
89 void wait_for_write(int node);
90 void release_write(int node);
91#ifdef DEBUG
92 void print_buffer(int node, int me);
93#endif
94 public:
108 ShmMessageGrp(int nprocs);
110 void sync();
111
113};
114
115}
116
117#endif
118
119// Local Variables:
120// mode: c++
121// c-file-style: "CLJ"
122// End:
int me()
Returns my processor number. In the range [0,n()).
Definition message.h:138
A template class that maintains references counts.
Definition ref.h:332
The ShmMessageGrp class is an implementation of MessageGrp that allows multiple process to be started...
Definition messshm.h:68
ShmMessageGrp(int nprocs)
Initialize ShmMessageGrp to use nprocs processors.
Ref< MessageGrp > clone(void)
Returns a copy of this MessageGrp specialization that provides an independent communication context.
void basic_recv(int type, void *data, int nbyte)
Must be implemented by specializations.
ShmMessageGrp()
Reads the number of processors from environmental variable NUMPROC.
ShmMessageGrp(const Ref< KeyVal > &)
The ShmMessageGrp KeyVal constructor takes a single keyword that specifies the number of processors.
void sync()
Synchronize all of the processors.
int basic_probe(int type)
Must be implemented by specializations.
void basic_send(int target, int type, const void *data, int nbyte)
Must be implemented by specializations.
Uses integer message types to send and receive messages.
Definition message.h:358
Definition messshm.h:47
Definition messshm.h:55

Generated at Thu Jan 25 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.11.0.