diff --git a/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.cc b/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.cc new file mode 100644 index 0000000000000000000000000000000000000000..75a4a952e07b950390dff83182413331950e4676 --- /dev/null +++ b/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.cc @@ -0,0 +1,79 @@ +//# FCNP_ClientStream.cc: Fast Collective Network Protocol Stream +//# +//# Copyright (C) 2008 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program 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 General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +//# Always #include <lofar_config.h> first! +#include <lofar_config.h> + +#if defined HAVE_FCNP && defined HAVE_BGP + +#include <Common/Timer.h> +#include <FCNP_ClientStream.h> + +#include <fcnp_cn.h> + +//#include <algorithm> + + +namespace LOFAR { +namespace CS1 { + + +FCNP_ClientStream::~FCNP_ClientStream() +{ +} + + +void FCNP_ClientStream::read(void *ptr, size_t size) +{ + //std::clog << "FCNP_ClientStream::read(" << std::hex << ptr << ", " << std::dec << size << ", ...)" << std::endl; + + if (reinterpret_cast<size_t>(ptr) % 16 != 0 || size % 16 != 0) { + size_t alignedSize = (size + 15) & ~ (size_t) 15; + char tmp[alignedSize] __attribute__ ((aligned(16))); + + FCNP_CN::IONtoCN_ZeroCopy(tmp, alignedSize); + memcpy(ptr, tmp, size); + } else { + FCNP_CN::IONtoCN_ZeroCopy(ptr, size); + } +} + + +void FCNP_ClientStream::write(const void *ptr, size_t size) +{ + //std::clog << "FCNP_ClientStream::write(" << std::hex << ptr << ", " << std::dec << size << ", ...)" << std::endl; + + if (reinterpret_cast<size_t>(ptr) % 16 != 0 || size % 16 != 0) { + size_t alignedSize = (size + 15) & ~ (size_t) 15; + char tmp[alignedSize] __attribute__ ((aligned(16))); + + memcpy(tmp, ptr, size); + FCNP_CN::CNtoION_ZeroCopy(tmp, alignedSize); + } else { + FCNP_CN::CNtoION_ZeroCopy(ptr, size); + } +} + +} // namespace CS1 +} // namespace LOFAR + +#endif diff --git a/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.h b/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.h new file mode 100644 index 0000000000000000000000000000000000000000..a623b456fc623f514d804b6b44deb21e4605d71e --- /dev/null +++ b/Appl/CEP/CS1/CS1_BGLProc/src/FCNP_ClientStream.h @@ -0,0 +1,46 @@ +//# FCNP_ClientStream.h: Stream that implements FCNP protocol +//# +//# Copyright (C) 2005 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program 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 General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef LOFAR_FCNP_CLIENT_STREAM_H +#define LOFAR_FCNP_CLIENT_STREAM_H + +#if defined HAVE_FCNP && defined HAVE_BGP + +#include <Stream/Stream.h> + +namespace LOFAR { +namespace CS1 { + +class FCNP_ClientStream : public Stream +{ + public: + virtual ~FCNP_ClientStream(); + + virtual void read(void *ptr, size_t size); + virtual void write(const void *ptr, size_t size); +}; + +} // namespace CS1 +} // namespace LOFAR + +#endif +#endif diff --git a/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.cc b/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.cc new file mode 100644 index 0000000000000000000000000000000000000000..236431e226dcaac3de78edaf77687f31a919f2f4 --- /dev/null +++ b/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.cc @@ -0,0 +1,114 @@ +//# FCNP.cc: Fast Collective Network Protocol +//# +//# Copyright (C) 2008 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program 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 General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +//# Always #include <lofar_config.h> first! +#include <lofar_config.h> + +#if defined HAVE_FCNP && defined __PPC__ + +#include <Common/Timer.h> +#include <FCNP_ServerStream.h> + +#include <fcnp_ion.h> + +#include <algorithm> + + +namespace LOFAR { +namespace CS1 { + + +std::vector<FCNP_ServerStream *> FCNP_ServerStream::allStreams; + + +FCNP_ServerStream::FCNP_ServerStream(unsigned core) +: + itsCore(core) +{ + if (allStreams.size() <= core) + allStreams.resize(core + 1); + + allStreams[core] = this; +} + + +FCNP_ServerStream::~FCNP_ServerStream() +{ + *std::find(allStreams.begin(), allStreams.end(), this) = 0; +} + + +#if 0 +void FCNP_ServerStream::createAllFCNP_ServerStreams(unsigned nrCoresPerPset) +{ + allStreams.resize(nrCoresPerPset); + + for (unsigned core = 0; core < nrCoresPerPset; core ++) + allStreams[core] = new FCNP_ServerStream(core); +} + + +void FCNP_ServerStream::deleteAllFCNP_ServerStreams() +{ + for (unsigned core = 0; core < allStreams.size(); core ++) + delete allStreams[core]; + + allStreams.clear(); +} +#endif + + +void FCNP_ServerStream::write(const void *buf, size_t size) +{ + //std::clog << "FCNP_ServerStream::write(" << std::hex << buf << ", " << std::dec << size << ") to " << itsCore << std::endl; + + if (reinterpret_cast<size_t>(buf) % 16 != 0 || size % 16 != 0) { + size_t alignedSize = (size + 15) & ~ (size_t) 15; + char tmp[alignedSize] __attribute__ ((aligned(16))); + + memcpy(tmp, buf, size); + FCNP_ION::IONtoCN_ZeroCopy(itsCore, tmp, alignedSize); + } else { + FCNP_ION::IONtoCN_ZeroCopy(itsCore, const_cast<const void *>(buf), size); + } +} + + +void FCNP_ServerStream::read(void *buf, size_t size) +{ + //std::clog << std::dec << "FCNP_ServerStream::read(" << std::hex << buf << ", " << std::dec << size << ") from " << itsCore << std::endl; + + if (reinterpret_cast<size_t>(buf) % 16 != 0 || size % 16 != 0) { + size_t alignedSize = (size + 15) & ~ (size_t) 15; + char tmp[alignedSize] __attribute__ ((aligned(16))); + + FCNP_ION::CNtoION_ZeroCopy(itsCore, tmp, alignedSize); + memcpy(buf, tmp, size); + } else { + FCNP_ION::CNtoION_ZeroCopy(itsCore, buf, size); + } +} + +} // namespace CS1 +} // namespace LOFAR + +#endif diff --git a/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.h b/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.h new file mode 100644 index 0000000000000000000000000000000000000000..8caea25a5559ab4a688204a3a865d0055e805dc8 --- /dev/null +++ b/Appl/CEP/CS1/CS1_IONProc/src/FCNP_ServerStream.h @@ -0,0 +1,61 @@ +//# TH_FCNP_Server.h: TransportHolder that implements FCNP protocol +//# +//# Copyright (C) 2005 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program 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 General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef LOFAR_TRANSPORT_FCNP_SERVER_STREAM_H +#define LOFAR_TRANSPORT_FCNP_SERVER_STREAM_H + +#if defined HAVE_FCNP && defined __PPC__ + +#include <Stream/Stream.h> +#include <vector> + +namespace LOFAR { +namespace CS1 { + +class FCNP_ServerStream : public Stream +{ + public: + FCNP_ServerStream(unsigned core); + virtual ~FCNP_ServerStream(); + +#if 0 + static void createAllTH_FCNP_Servers(unsigned nrCoresPerPset); + static void deleteAllTH_FCNP_Servers(); +#endif + + virtual void read(void *ptr, size_t size); + virtual void write(const void *ptr, size_t size); + + private: + // create via createAllTH_FCNP_Servers(...) + + static std::vector<FCNP_ServerStream *> allStreams; + + private: + unsigned itsCore; +}; + +} // namespace CS1 +} // namespace LOFAR + +#endif +#endif