Skip to content

Commit

Permalink
Fix warnings of C++ 17 compiler (#166)
Browse files Browse the repository at this point in the history
Signed-off-by: siyuan0322 <[email protected]>
  • Loading branch information
siyuan0322 authored Aug 8, 2024
1 parent 16b38c0 commit 8cb5b42
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 29 deletions.
4 changes: 2 additions & 2 deletions examples/analytical_apps/bc/staged_bc_bfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class StagedBCBFS : public ParallelAppBase<FRAG_T, BCContext<FRAG_T>,
});

// sync messages to other workers
ForEach(ctx.curr_inner_updated, [next_depth, &frag, &ctx, &channels](
int tid, vertex_t v) {
ForEach(ctx.curr_inner_updated, [next_depth, &frag, &ctx](int tid,
vertex_t v) {
auto oes = frag.GetOutgoingAdjList(v);
double pn = ctx.path_num[v];
for (auto& e : oes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CoreDecomposition
});
ctx.curr_inner_updated.ParallelClear(GetThreadPool());

ForEach(ctx.next_inner_updated, [&frag, &ctx](int tid, vertex_t v) {
ForEach(ctx.next_inner_updated, [&ctx](int tid, vertex_t v) {
if (ctx.partial_result[v] > ctx.level) {
int new_core = ctx.partial_result[v] - ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
Expand Down Expand Up @@ -115,7 +115,7 @@ class CoreDecomposition
});
ctx.curr_inner_updated.ParallelClear(GetThreadPool());

ForEach(ctx.next_inner_updated, [&frag, &ctx](int tid, vertex_t v) {
ForEach(ctx.next_inner_updated, [&ctx](int tid, vertex_t v) {
if (ctx.partial_result[v] > ctx.level) {
int new_core = ctx.partial_result[v] - ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
Expand Down Expand Up @@ -149,7 +149,7 @@ class CoreDecomposition
ctx.next_inner_updated.Insert(v);
});

ForEach(ctx.next_inner_updated, [&frag, &ctx](int tid, vertex_t v) {
ForEach(ctx.next_inner_updated, [&ctx](int tid, vertex_t v) {
if (ctx.partial_result[v] > ctx.level) {
int new_core = ctx.partial_result[v] - ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
Expand Down Expand Up @@ -219,7 +219,7 @@ class CoreDecomposition
});
ctx.curr_inner_updated.ParallelClear(GetThreadPool());

ForEach(ctx.next_inner_updated, [&frag, &ctx](int tid, vertex_t v) {
ForEach(ctx.next_inner_updated, [&ctx](int tid, vertex_t v) {
if (ctx.partial_result[v] > ctx.level) {
int new_core = ctx.partial_result[v] - ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
Expand Down
27 changes: 13 additions & 14 deletions examples/analytical_apps/kcore/kcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,19 @@ class KCore : public ParallelAppBase<FRAG_T, KCoreContext<FRAG_T>,
});

ctx.next_inner_updated.ParallelClear(GetThreadPool());
ForEach(ctx.curr_inner_updated,
[&frag, &ctx, &channels](int tid, vertex_t v) {
if (ctx.partial_result[v] >= ctx.k) {
ctx.partial_result[v] -= ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;

if (ctx.partial_result[v] < ctx.k) {
ctx.next_inner_updated.Insert(v);
}
} else {
ctx.partial_result[v] -= ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
}
});
ForEach(ctx.curr_inner_updated, [&ctx](int tid, vertex_t v) {
if (ctx.partial_result[v] >= ctx.k) {
ctx.partial_result[v] -= ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;

if (ctx.partial_result[v] < ctx.k) {
ctx.next_inner_updated.Insert(v);
}
} else {
ctx.partial_result[v] -= ctx.reduced_degrees[v];
ctx.reduced_degrees[v] = 0;
}
});

ctx.curr_inner_updated.ParallelClear(GetThreadPool());
ForEach(ctx.next_inner_updated, [&frag, &ctx](int tid, vertex_t v) {
Expand Down
3 changes: 2 additions & 1 deletion examples/analytical_apps/kcore/kcore_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class KCoreContext : public VertexDataContext<FRAG_T, int> {
}
}

LOG(INFO) << "[frag-" << frag.fid() << "] " << "KCore: " << num;
LOG(INFO) << "[frag-" << frag.fid() << "] "
<< "KCore: " << num;
}

int k;
Expand Down
2 changes: 1 addition & 1 deletion grape/cuda/utils/cuda_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ size_t get_rss(bool include_shared_memory) {
if (include_shared_memory) {
return (size_t) rss * (size_t) sysconf(_SC_PAGESIZE);
} else {
return (size_t) (rss - shared_rss) * (size_t) sysconf(_SC_PAGESIZE);
return (size_t)(rss - shared_rss) * (size_t) sysconf(_SC_PAGESIZE);
}
#else
/* Unknown OS ----------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion grape/cuda/utils/work_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct WorkSourceRange {
public:
DEV_HOST WorkSourceRange(T start, size_t size) : start_(start), size_(size) {}

DEV_HOST_INLINE T GetWork(size_t i) const { return (T) (start_ + i); }
DEV_HOST_INLINE T GetWork(size_t i) const { return (T)(start_ + i); }

DEV_HOST_INLINE size_t size() const { return size_; }

Expand Down
2 changes: 1 addition & 1 deletion grape/parallel/thread_local_message_buffer_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ThreadLocalMessageBufferOpt {
to_send_.resize(fnum_);

for (auto& arc : to_send_) {
arc.init(std::move(pool_->take_default()));
arc.init(pool_->take_default());
}

sent_size_ = 0;
Expand Down
8 changes: 8 additions & 0 deletions grape/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ struct InternalOID<std::string> {
static std::string FromInternal(const type& val) { return std::string(val); }
};

#ifdef __cpp_lib_is_invocable
template <class T, typename... Args>
using result_of_t = std::invoke_result_t<T, Args...>;
#else
template <class T, typename... Args>
using result_of_t = typename std::result_of<T(Args...)>::type;
#endif

} // namespace grape

#endif // GRAPE_TYPES_H_
3 changes: 2 additions & 1 deletion grape/utils/concurrent_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class SpinLock {
public:
void lock() {
while (locked.test_and_set(std::memory_order_acquire)) {
{}
{
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion grape/utils/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <glog/logging.h>

#include "grape/parallel/parallel_engine_spec.h"
#include "grape/types.h"

#if __linux__
#ifndef _GNU_SOURCE
Expand All @@ -58,7 +59,7 @@ class ThreadPool {

template <class F, class... Args>
auto enqueue(F&& f, Args&&... args)
-> std::future<typename std::result_of<F(Args...)>::type>;
-> std::future<grape::result_of_t<F, Args...>>;
inline int GetThreadNum() { return thread_num_; }
void WaitEnd(std::vector<std::future<void>>& results);
~ThreadPool();
Expand Down
3 changes: 0 additions & 3 deletions grape/worker/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ class Worker {
context_->Init(messages_, std::forward<Args>(args)...);
processMutation();

int round = 0;

messages_.Start();

messages_.StartARound();
Expand All @@ -126,7 +124,6 @@ class Worker {

while (!messages_.ToTerminate()) {
t = GetCurrentTime();
round++;
messages_.StartARound();

runIncEval();
Expand Down

0 comments on commit 8cb5b42

Please sign in to comment.