// // memarmci.cc // based on memshm.cc // // Copyright (C) 1996 Limit Point Systems, Inc. // // Author: Curtis Janssen // Maintainer: SNL // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #ifndef _util_group_memarmci_cc #define _util_group_memarmci_cc #ifdef __GNUC__ #pragma implementation #endif extern "C" { #include } #include #include #include #include using namespace sc; static ClassDesc ARMCIMemoryGrp_cd( typeid(ARMCIMemoryGrp),"ARMCIMemoryGrp",1,"public RDMAMemoryGrp", 0, create, 0); ARMCIMemoryGrp::ARMCIMemoryGrp(const Ref& msg): RDMAMemoryGrp(msg) { init(); } ARMCIMemoryGrp::ARMCIMemoryGrp(const Ref& keyval): RDMAMemoryGrp(keyval) { init(); } void ARMCIMemoryGrp::init() { armci_lock_ = ThreadGrp::get_default_threadgrp()->new_lock(); //debug_ = 1; all_data_ = 0; ARMCI_Init(); } void ARMCIMemoryGrp::finalize() { set_localsize(0); ARMCI_Finalize(); } void ARMCIMemoryGrp::set_localsize(size_t localsize) { ARMCI_AllFence(); // this will initialize the offsets_ array RDMAMemoryGrp::set_localsize(localsize); if (all_data_) { ARMCI_Free(data_); delete[] all_data_; all_data_ = 0; data_ = 0; ARMCI_Destroy_mutexes(); } if (localsize == 0) return; all_data_ = new void*[n()]; int r; r = ARMCI_Malloc(all_data_, localsize); data_ = reinterpret_cast(all_data_[me()]); if (debug_) { for (int i=0; iclass_desc()); return buf; } void ARMCIMemoryGrp::free_local(void *data) { ARMCI_Free_local(data); } ARMCIMemoryGrp::~ARMCIMemoryGrp() { finalize(); } void ARMCIMemoryGrp::print(std::ostream &o) const { RDMAMemoryGrp::print(o); } #endif ///////////////////////////////////////////////////////////////////////////// // Local Variables: // mode: c++ // c-file-style: "CLJ" // End: