我正在执行一些有关HPX中远程通信的简单测试,这些测试经过编译使得宗地基于MPI。 我面临一些有关带宽和通信延迟的问题。
通过以下简单代码执行测试:
import plotly.offline as offline
import plotly.plotly as py
import plotly.figure_factory as ff
import plotly.graph_objs as go
import plotly.io as pio
import pandas as pd
import numpy as np
filePath="test.data"
df = pd.read_table(filePath,
header=None,
usecols=[1,2, 4],
sep='\t',
converters={1:np.datetime64, 3:np.datetime64},
)
df.columns = ['Start','Task', 'Finish']
df['Resource'] = 'Done'
colors = {'Done': 'rgb(0, 240, 0)',}
fig = ff.create_gantt(df,
title='My Tasks',
bar_width=0.1,
showgrid_x=False,
showgrid_y=False,
colors=colors,
index_col='Resource',
show_colorbar = True,
group_tasks=True,
)
fig['layout'].update(plot_bgcolor = 'rgba(0,0,0,250)',
paper_bgcolor = 'rgba(0,0,0,0)',
showlegend = True,
)
offline.plot(fig, image = 'png', image_filename='test', output_type='file', image_width=500, image_height=500, filename='test.html')
在Intel Omnipath群集上运行测试,我得到以下值:
#include <iostream>
#include <chrono>
#include <hpx/hpx_main.hpp>
#include <hpx/include/components.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/iostreams.hpp>
class block
: public hpx::components::component_base<block>
{
public:
block(std::size_t size) : data_(size,1){ }
std::vector<double> get_data(){return data_;}
int pingpong(){return 1;}
HPX_DEFINE_COMPONENT_ACTION(block, get_data, get_data_action);
HPX_DEFINE_COMPONENT_ACTION(block, pingpong, pingpong_action);
private:
std::vector<double> data_;
};
typedef hpx::components::component<block> block_type;
typedef block::get_data_action block__get_data_action;
typedef block::pingpong_action block__pingpong_action;
HPX_REGISTER_COMPONENT(block_type, block);
HPX_REGISTER_ACTION(block::get_data_action, block__get_data_action);
HPX_REGISTER_ACTION(block::pingpong_action, block__pingpong_action);
////////////////////////////////////////////////////////////////////
int main(){
std::vector<hpx::id_type> locs = hpx::find_all_localities();
std::size_t minsize=1e3;
std::size_t maxsize=1e8;
std::size_t ntries = 100;
block__get_data_action act_data;
block__pingpong_action act_pingpong;
for(std::size_t size = minsize; size<=maxsize; size*=2){
hpx::id_type remote_block = hpx::new_<block_type>(locs[1], size).get();
double Mb_size=size*sizeof(double)/1.e6;
hpx::cout << "Size = " << Mb_size << " MB.";
//---------------- Bandwidth ------------------
double seconds_bandwidth=0;
std::vector<double> buffer(size);
for(int i=0; i<ntries; i++){
auto t = std::chrono::high_resolution_clock::now();
buffer = act_data(remote_block);
auto elapsed = std::chrono::high_resolution_clock::now() - t;
seconds_bandwidth+=std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count()/1.e6;
}
seconds_bandwidth/=double(ntries);
hpx::cout << "\t Bandwidth = " << Mb_size/seconds_bandwidth << " MB/s.";
//---------------- PingPong ------------------
double microseconds_pingpong=0;
int intbuffer=0;
for(int i=0; i<ntries; i++){
auto t = std::chrono::high_resolution_clock::now();
intbuffer=act_pingpong(remote_block);
auto elapsed = std::chrono::high_resolution_clock::now() - t;
microseconds_pingpong+=std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count();
}
microseconds_pingpong/=double(ntries);
hpx::cout << "\t PingPong = " << microseconds_pingpong << " microseconds. " << hpx::endl;
}
return 0;
}
对我来说奇怪的是:
因此,我有以下问题:
如果您需要更多信息,例如有关HPX编译和配置的信息,请随时询问。 这几天我正在使用HPX,所以我可能在代码中出现了一些错误或某些非最佳错误(对此很抱歉)。
非常感谢!