1 /* ---------------------------------------------------------------------- 2 CSlib - Client/server library for code coupling 3 http://cslib.sandia.gov, Sandia National Laboratories 4 Steve Plimpton, sjplimp@sandia.gov 5 6 Copyright 2018 National Technology & Engineering Solutions of 7 Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with 8 NTESS, the U.S. Government retains certain rights in this software. 9 This software is distributed under the modified Berkeley Software 10 Distribution (BSD) License. 11 12 See the README file in the top-level CSlib directory. 13 ------------------------------------------------------------------------- */ 14 15 #ifndef CSLIB_H 16 #define CSLIB_H 17 18 #include <stdint.h> 19 20 #if defined(LAMMPS_BIGBIG) 21 #error CSlib is not compatible with -DLAMMPS_BIGBIG 22 #endif 23 24 namespace CSLIB_NS { 25 26 class CSlib { 27 public: 28 int nsend,nrecv; 29 30 CSlib(int, const char *, const void *, const void *); 31 ~CSlib(); 32 33 void send(int, int); 34 35 void pack_int(int, int); 36 void pack_int64(int, int64_t); 37 void pack_float(int, float); 38 void pack_double(int, double); 39 void pack_string(int, char *); 40 void pack(int, int, int, void *); 41 void pack_parallel(int, int, int, int *, int, void *); 42 43 int recv(int &, int *&, int *&, int *&); 44 45 int unpack_int(int); 46 int64_t unpack_int64(int); 47 float unpack_float(int); 48 double unpack_double(int); 49 char *unpack_string(int); 50 void *unpack(int); 51 void unpack(int, void *); 52 void unpack_parallel(int, int, int *, int, void *); 53 54 int extract(int); 55 56 private: 57 uint64_t myworld; // really MPI_Comm, but avoids use of mpi.h in this file 58 // so apps can include this file w/ no MPI on system 59 int me,nprocs; 60 int client,server; 61 int nfield,maxfield; 62 int msgID,fieldcount; 63 int nheader,maxheader; 64 int nbuf,maxbuf; 65 int maxglobal,maxfieldbytes; 66 int *fieldID,*fieldtype,*fieldlen,*fieldoffset; 67 int *header; 68 int *recvcounts,*displs; // nprocs size for Allgathers 69 int *allids; // nglobal size for pack_parallel() 70 char *buf; // maxbuf size for msg with all fields 71 char *fielddata; // maxfieldbytes size for one global field 72 const char *pad; 73 74 class Msg *msg; 75 76 void send_message(); 77 void onefield(int, int, int &, int &); 78 int find_field(int, int); 79 void allocate_fields(); 80 void deallocate_fields(); 81 int64_t roundup(int64_t, int); 82 void *smalloc(int); 83 void *srealloc(void *, int); 84 void sfree(void *); 85 void error_all(const char *); 86 void error_one(const char *); 87 }; 88 89 } 90 91 #endif 92