GPP广播容错测试

    GPP中广播是容错的,这就是说,在广播的过程中,如果强制杀死几个进程,广播依然不受影响。为了验证其容错功能,编写以下测试程序:

    

/*
 * main.cpp
 *
 *  Created on: Apr 9, 2013
 *      Author: lichao
 */
#include "gpp.h"
#include <cstdlib>

class Packet : public GPP::Serializable
{
public:
	Packet()
	{
		_buf = NULL;
		_size = 0;
	}

	Packet(char * buf,int size)
	{
		_buf = (char *) malloc(size);
		memcpy(_buf,buf,size);
		_size = size;
	}
	virtual ~Packet()
	{
		if(!_buf)
		{
			free(_buf);
			_buf = NULL;
		}
	}
	void writeObject(GPP::DataStream& out)
	{
		out << _size;
		out.writeRawData(_buf,_size);
	}
	void readObject(GPP::DataStream& in)
	{
		in >> _size;
		_buf = (char *)malloc(_size);
		in.readRawData(_buf,_size);
	}
private:
	char * _buf;
	int _size;

};


class Handler : public GPP::BcastHandler<Packet>
{
public:
	Handler(){}
	virtual ~Handler()
	{

	}
	void handle(GPP::SharedPtr<Packet>& obj)
	{
		counter++;

		GPP::Log::Info("Received data for %5d.",counter);
		fflush(stdout);

	}
	static int getCounter()
	{
		return counter;
	}
private:
	static int counter;
};

int Handler::counter = 0;

int main(int argc,char *argv[])
{
	GPP::Init();
	GPP::Comm::RegisterHandler(99,new Handler());
	int size;
	char * buf;
	int rank = GPP::Comm::GetRank();
	if(rank == 0)
	{
		size = 1 << 25;
		buf = (char *)malloc(size);
		Packet * p = new Packet(buf,size);
		int loops = 100;
		while(loops--)
		{
			int rc = GPP::Comm::Bcast(p,99);
			if(rc < 0)
			{
				GPP::Log::Error(GPP::StrErr(rc));
				fflush(stdout);
			}
		}
		delete p;
	}
	GPP::MPI_Barrier(100);
	GPP::Log::Trace("Counter is %5d\n",Handler::getCounter());
	GPP::Finalize();
	return 0;
}

    程序使用计数器来验证广播的容错设计,即不能出现丢包。

    测试结果发现:强制杀死进程后,广播将挂起,即不能继续往下执行。这说明GPP中的广播在容错设计方面还有bug。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值