Gemini代码摘抄(一)Graph和init
来源:互联网 发布:英语教师网络研修心得 编辑:程序博客网 时间:2024/06/16 09:58
Graph和init
在pagerank.cpp中对图进行初始化:
Graph<Empty> * graph; graph = new Graph<Empty>();
具体实现在graph.hpp中,设置threads和sockets,其中threads—cpus—partitions,sockets—nodes—machines,threads_per_socket表示每个节点(机器)上分到的线程数(分区数):
Graph() { threads = numa_num_configured_cpus(); sockets = numa_num_configured_nodes(); threads_per_socket = threads / sockets; init(); }
init()函数设置分区数
void init() { edge_data_size = std::is_same<EdgeData, Empty>::value ? 0 : sizeof(EdgeData); unit_size = sizeof(VertexId) + edge_data_size; edge_unit_size = sizeof(VertexId) + unit_size; assert( numa_available() != -1 ); assert( sizeof(unsigned long) == 8 ); // assume unsigned long is 64-bit char nodestring[sockets*2+1]; nodestring[0] = '0'; for (int s_i=1;s_i<sockets;s_i++) { nodestring[s_i*2-1] = ','; nodestring[s_i*2] = '0'+s_i; } struct bitmask * nodemask = numa_parse_nodestring(nodestring); numa_set_interleave_mask(nodemask); omp_set_dynamic(0); omp_set_num_threads(threads); thread_state = new ThreadState * [threads]; local_send_buffer_limit = 16; local_send_buffer = new MessageBuffer * [threads]; for (int t_i=0;t_i<threads;t_i++) { thread_state[t_i] = (ThreadState*)numa_alloc_onnode( sizeof(ThreadState), get_socket_id(t_i)); local_send_buffer[t_i] = (MessageBuffer*)numa_alloc_onnode( sizeof(MessageBuffer), get_socket_id(t_i)); local_send_buffer[t_i]->init(get_socket_id(t_i)); } #pragma omp parallel for for (int t_i=0;t_i<threads;t_i++) { int s_i = get_socket_id(t_i); assert(numa_run_on_node(s_i)==0); #ifdef PRINT_DEBUG_MESSAGES printf("thread-%d bound to socket-%d\n", t_i, s_i); #endif } #ifdef PRINT_DEBUG_MESSAGES printf("threads=%d*%d\n", sockets, threads_per_socket); printf("interleave on %s\n", nodestring); #endif MPI_Comm_rank(MPI_COMM_WORLD, &partition_id); MPI_Comm_size(MPI_COMM_WORLD, &partitions); send_buffer = new MessageBuffer ** [partitions]; recv_buffer = new MessageBuffer ** [partitions]; for (int i=0;i<partitions;i++) { send_buffer[i] = new MessageBuffer * [sockets]; recv_buffer[i] = new MessageBuffer * [sockets]; for (int s_i=0;s_i<sockets;s_i++) { send_buffer[i][s_i] = (MessageBuffer*)numa_alloc_onnode( sizeof(MessageBuffer), s_i); send_buffer[i][s_i]->init(s_i); recv_buffer[i][s_i] = (MessageBuffer*)numa_alloc_onnode( sizeof(MessageBuffer), s_i); recv_buffer[i][s_i]->init(s_i); } } alpha = 8 * (partitions - 1); MPI_Barrier(MPI_COMM_WORLD); }
2.收到的边数是收到的byte数除以每条边的大小:
int recv_edges = recv_bytes / edge_unit_size;
3.点dst所在的分区号为dst_part,
dst_part分区中点src的出边加一
点dst的入度加一
点src的初度加一
__sync_fetch_and_add(&outgoing_adj_index[dst_part][src], 1);__sync_fetch_and_add(&in_degree[dst], 1);__sync_fetch_and_add(&out_degree[src], 1);
4.alpha值为分区个数乘以8
阅读全文
0 0
- Gemini代码摘抄(一)Graph和init
- Gemini代码摘抄(三)process_vertices
- Gemini代码摘抄(四)process_edges
- Gemini代码摘抄(二)load_directed
- 《peopleware》摘抄(一)
- Gemini
- 一、MP3文件概述(原创和摘抄)
- 精彩论文摘抄(一)
- android启动代码init.c文件分析(一)
- ecshop代码分析一(init.php文件)
- OSGI企业应用开发(六)细说Blueprint & Gemini Blueprint(一)
- OSGI企业应用开发(六)细说Blueprint & Gemini Blueprint(一)
- 摘抄 Android init.rc 翻译
- graph--数据结构试验(代码)
- gloox代码分析 - 注册模块(摘抄)
- 数据结构总结(摘抄)(一)
- 2013年读书摘抄(一)
- Visual C++ 概念:移植和升级 (MSDN 摘抄的,就一盗版)
- jquery使用 Form submission canceled because the form is not connected
- 云上架构和传统IT架构的区别在哪里?(企业CIO、CTO必读)
- 注解anoation原理及自定义注解demo实现
- callback的理解与Java实例
- Object-C知识点 (四)NSObject的继承关系
- Gemini代码摘抄(一)Graph和init
- codeVS 1011 数的计算
- oracle--基本转换函数
- GC日志分析
- nutch 执行流程以及简介
- JZOJ2017.08.15 B组
- 38061087
- 数据库分库分表(转)
- 分布式集群的一些理解和概念。