Skip to content
Snippets Groups Projects
Commit ea12cc54 authored by John Romein's avatar John Romein
Browse files

bug 225:

removed TH_* dependencies
parent 722c7bf8
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@
#include <Stream/FileStream.h>
#include <Stream/NullStream.h>
#include <Stream/SocketStream.h>
#include <CS1_BGLProc/TH_ZoidClient.h>
#include <CS1_BGLProc/LocationInfo.h>
#include <CS1_BGLProc/BGL_Processing.h>
#include <CS1_BGLProc/Package__Version.h>
......
......@@ -6,8 +6,6 @@
#include <CS1_Interface/Allocator.h>
#include <Stream/Stream.h>
#include <TH_ZoidClient.h>
#include <boost/multi_array.hpp>
......
......@@ -9,7 +9,6 @@
#include <Stream/Stream.h>
#include <CS1_Interface/Allocator.h>
#include <TH_ZoidClient.h>
#include <boost/multi_array.hpp>
......
//# TH_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 HAVE_BGP
#include <Common/Timer.h>
#include <Transport/DataHolder.h>
#include <TH_FCNP_Client.h>
#include <fcnp_cn.h>
#include <algorithm>
namespace LOFAR {
namespace CS1 {
TH_FCNP_Client::~TH_FCNP_Client()
{
}
bool TH_FCNP_Client::init()
{
return true;
}
bool TH_FCNP_Client::sendBlocking(void *buf, int size, int unaligned, DataHolder *)
{
//std::clog << std::dec << "TH_FCNP_Client::sendBlocking(" << buf << ", " << size << ", ...)" << std::endl;
if (unaligned) {
size_t alignedSize = (size + 15) & ~ (size_t) 15;
char tmp[alignedSize] __attribute__ ((aligned(16)));
memcpy(tmp, buf, size);
FCNP_CN::CNtoION_ZeroCopy(tmp, alignedSize);
} else {
FCNP_CN::CNtoION_ZeroCopy(const_cast<const void *>(buf), size);
}
return true;
}
bool TH_FCNP_Client::recvBlocking(void *buf, int size, int unaligned, int, DataHolder *)
{
//std::clog << std::dec << "TH_FCNP_Client::recvBlocking(" << buf << ", " << size << ", ...)" << std::endl;
if (unaligned) {
size_t alignedSize = (size + 15) & ~ (size_t) 15;
char tmp[alignedSize] __attribute__ ((aligned(16)));
FCNP_CN::IONtoCN_ZeroCopy(tmp, alignedSize);
memcpy(buf, tmp, size);
} else {
FCNP_CN::IONtoCN_ZeroCopy(buf, size);
}
return true;
}
// functions below are not supported
int32 TH_FCNP_Client::recvNonBlocking(void *, int32, int, int32, DataHolder *)
{
return false;
}
void TH_FCNP_Client::waitForReceived(void *, int, int)
{
}
bool TH_FCNP_Client::sendNonBlocking(void *, int, int, DataHolder *)
{
return false;
}
void TH_FCNP_Client::waitForSent(void *, int, int)
{
}
string TH_FCNP_Client::getType() const
{
return "TH_FCNP_Client";
}
bool TH_FCNP_Client::isClonable() const
{
return true;
}
TransportHolder *TH_FCNP_Client::clone() const
{
return new TH_FCNP_Client;
}
void TH_FCNP_Client::reset()
{
}
} // namespace CS1
} // namespace LOFAR
#endif
//# TH_FCNP_Client.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_TRANSPORTTH_FCNP_CLIENT_H
#define LOFAR_TRANSPORTTH_FCNP_CLIENT_H
#if defined HAVE_FCNP && defined HAVE_BGP
// \file
// TransportHolder that does nothing
//# Never #include <config.h> or #include <lofar_config.h> in a header file!
//# Includes
#include <Transport/TransportHolder.h>
namespace LOFAR {
namespace CS1 {
class TH_FCNP_Client : public TransportHolder
{
public:
TH_FCNP_Client() {}
virtual ~TH_FCNP_Client();
virtual bool init();
virtual bool recvBlocking(void *ptr, int size, int unaligned, int, DataHolder *);
virtual bool sendBlocking(void *ptr, int size, int unaligned, DataHolder *);
static void sendCompleted(void *ptr, void *arg);
// functions below are not supported
virtual int32 recvNonBlocking(void *, int32, int, int32, DataHolder *);
virtual void waitForReceived(void *, int, int);
virtual bool sendNonBlocking (void *, int, int, DataHolder *);
virtual void waitForSent(void *, int, int);
virtual string getType() const;
virtual bool isClonable() const;
virtual TransportHolder* clone() const;
virtual void reset();
// Copying is not allowed
TH_FCNP_Client(const TH_FCNP_Client& that);
TH_FCNP_Client& operator=(const TH_FCNP_Client& that);
};
} // namespace CS1
} // namespace LOFAR
#endif
#endif
//# TH_ZoidClient.cc: In-memory transport mechanism
//#
//# Copyright (C) 2000, 2001
//# 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_ZOID && defined HAVE_BGL
#include <Transport/DataHolder.h>
#include <CS1_BGLProc/TH_ZoidClient.h>
extern "C" {
#include <lofar.h>
}
namespace LOFAR {
namespace CS1 {
#if 0
static unsigned checksum(const void *buf, size_t size)
{
unsigned sum = 0;
for (int i = 0; i < (int) (size / sizeof(unsigned)); i ++)
sum ^= ((unsigned *) buf)[i];
return sum;
}
#endif
bool TH_ZoidClient::recvBlocking(void *buf, int nbytes, int onecopy, int, DataHolder *)
{
//std::clog << "TH_ZoidClient::recvBlocking(" << buf << ", " << nbytes << "...)" << std::endl;
static size_t maxBytes = ~ (size_t) 0;
for (size_t bytesRead = 0; bytesRead < (size_t) nbytes;) {
size_t count = std::min(nbytes - bytesRead, maxBytes);
(onecopy ? lofar_ion_to_cn_onecopy : lofar_ion_to_cn_zerocopy)(static_cast<char *>(buf) + bytesRead, &count);
switch (__zoid_error()) {
case 0 : bytesRead += count;
break;
case E2BIG : maxBytes = nbytes - __zoid_excessive_size();
break;
default : return false;
}
}
return true;
}
bool TH_ZoidClient::sendBlocking(void *buf, int nbytes, int onecopy, DataHolder *)
{
//std::clog << "TH_ZoidClient::sendBlocking(" << buf << ", " << nbytes << "...)" << std::endl;
static size_t maxBytes = ~ (size_t) 0;
for (size_t bytesWritten = 0; bytesWritten < (size_t) nbytes;) {
size_t count = std::min(nbytes - bytesWritten, maxBytes);
count = (onecopy ? lofar_cn_to_ion_onecopy : lofar_cn_to_ion_zerocopy)(static_cast<char *>(buf) + bytesWritten, count);
switch (__zoid_error()) {
case 0 : bytesWritten += count;
break;
case E2BIG : maxBytes = nbytes - __zoid_excessive_size();
break;
default : return false;
}
}
return true;
}
} // namespace CS1
} // namespace LOFAR
#endif
//# TH_ZoidClient.h: TransportHolder that does nothing
//#
//# 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_TRANSPORTTH_ZOID_CLIENT_H
#define LOFAR_TRANSPORTTH_ZOID_CLIENT_H
#if defined HAVE_BGL
// \file
// TransportHolder that does nothing
//# Never #include <config.h> or #include <lofar_config.h> in a header file!
//# Includes
#include <Transport/TransportHolder.h>
namespace LOFAR {
namespace CS1 {
class TH_ZoidClient : public TransportHolder
{
public:
TH_ZoidClient(){};
virtual ~TH_ZoidClient(){};
virtual bool init() {return true;};
// if doCopy == 0, Zoid's zero-copy protocol is used; memory must be
// obtained through __zoid_alloc and must be a multiple of 32
virtual bool recvBlocking(void *ptr, int size, int doCopy, int, DataHolder*);
virtual bool sendBlocking(void *ptr, int size, int doCopy, DataHolder*);
virtual int32 recvNonBlocking (void*, int32, int, int32, DataHolder*)
{ return true; }
virtual void waitForReceived(void*, int, int)
{}
virtual bool sendNonBlocking (void*, int, int, DataHolder*)
{ return true; }
virtual void waitForSent(void*, int, int)
{}
virtual string getType() const
{ return "TH_ZoidClient"; }
virtual bool isClonable() const
{ return true; }
virtual TransportHolder* clone() const
{ return new TH_ZoidClient(); }
virtual void reset()
{}
private:
// Copying is not allowed
TH_ZoidClient(const TH_ZoidClient& that);
TH_ZoidClient& operator=(const TH_ZoidClient& that);
};
} // namespace CS1
} // namespace LOFAR
#endif
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment