void UvTool::relax_default( const AlignedVec4Array &half_distances, const Vec2Vector &uvs, const float damping, const float clamping, const Uint32 width, const Uint32 height, Vec2Vector &new_uvs) { glm::uvec2 size; Uint32 i, j; size = glm::uvec2(width, height); #pragma omp parallel for for (i = 0; i < width; ++i) { glm::uvec2 position; position.x = i; position.y = 0; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } #pragma omp parallel for private(i) for (j = 1; j < (height - 1); ++j) { glm::uvec2 position; position.x = 0; position.y = j; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); for (i = 1; i < (width - 1); ++i) { relax(half_distances, uvs, damping, clamping, width, i + j * width, new_uvs); } position.x = width - 1; position.y = j; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } #pragma omp parallel for for (i = 0; i < width; ++i) { glm::uvec2 position; position.x = i; position.y = height - 1; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } }
void UvTool::relax_sse2( const AlignedVec4Array &half_distances, const Vec2Vector &uvs, const float damping, const float clamping, const Uint32 width, const Uint32 height, Vec2Vector &new_uvs) { glm::uvec2 size; Uint32 i; size = glm::uvec2(width, height); #pragma omp parallel for for (i = 0; i < width; ++i) { glm::uvec2 position; position.x = i; position.y = 0; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } #pragma omp parallel for for (i = 1; i < (height - 1); ++i) { glm::uvec2 position; SIMD::relax_uv_line(glm::value_ptr(uvs[i * width]), half_distances.get_ptr_at(i * width * 2), damping, clamping, width, glm::value_ptr(new_uvs[i * width])); position.x = 0; position.y = i; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); position.x = width - 1; position.y = i; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } #pragma omp parallel for for (i = 0; i < width; ++i) { glm::uvec2 position; position.x = i; position.y = height - 1; relax_edge(half_distances, uvs, position, size, damping, clamping, new_uvs); } }
void operator()(UpdateRequest& req, Galois::UserContext<UpdateRequest>& ctx) const { unsigned& data = graph.getData(req.second); if (req.first > data) return; for (Graph::edge_iterator ii = graph.edge_begin(req.second), ee = graph.edge_end(req.second); ii != ee; ++ii) relax_edge(data, ii, ctx); }
void operator()(UpdateRequest& req, Galois::UserContext<UpdateRequest>& ctx) const { Node& data = graph.getData(req.second); if (req.first.distance >= data.distance) return; data.distance = req.first.distance; data.path = req.first.path + " " + std::to_string(req.first.nodeId); for (Graph::edge_iterator ii = graph.edge_begin(req.second), ee = graph.edge_end(req.second); ii != ee; ++ii) relax_edge(data, ii, ctx); }
void dijkstra(WEIGHT weight, int len, int src) { INFO_OF_NODE info; init_node_info(info, len, src); HEAP heap; int i; for(i = 0; i < len; ++i) heap[i] = i; build_min_heap(heap, info, len); int rear = len; while(rear > 0) { int q = heap[0]; info[q].color = BLACK; heap[0] = heap[--rear]; heap[rear] = q; keep_heap_property(heap, info, 0, rear); int i; for(i = 0; i < len; ++i) { //cause dijkstra can't support negative weight. if(weight[q][i] > 0 && info[i].color == WHITE) { relax_edge(q, i, heap, info, weight); } } } for(i = 0; i < len; ++i) { print_shortest_path(info, i, src); if(info[i].path_len == LONG_MAX) printf(" can't reach.\n"); else printf(" weight of path = %d\n", info[i].path_len); } }