Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings #76

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/game_of_life.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int, char*[])
std::vector<redGrapes::FieldResource<Buffer, TaskType>> buffers;

for(size_t i = 0; i < 4; ++i)
buffers.emplace_back(new Buffer());
buffers.emplace_back();

int current = 0;

Expand Down
7 changes: 4 additions & 3 deletions examples/mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <redGrapes/scheduler/pool_scheduler.hpp>
#include <redGrapes/task/property/label.hpp>

#include <array>
#include <iostream>

/**
Expand Down Expand Up @@ -102,9 +103,9 @@ int main()
mpi_config.write());

// main loop
redGrapes::FieldResource<std::array<int, 4>, RGTask> field[2] = {
redGrapes::FieldResource<std::array<int, 4>, RGTask>(new std::array<int, 4>()),
redGrapes::FieldResource<std::array<int, 4>, RGTask>(new std::array<int, 4>()),
std::array<redGrapes::FieldResource<std::array<int, 4>, RGTask>, 2> field = {
redGrapes::FieldResource<std::array<int, 4>, RGTask>(),
redGrapes::FieldResource<std::array<int, 4>, RGTask>(),
};

int current = 0;
Expand Down
2 changes: 1 addition & 1 deletion redGrapes/dispatch/thread/worker_pool.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace redGrapes
workers.reserve(num_workers);

SPDLOG_DEBUG("populate WorkerPool with {} workers", num_workers);
for(size_t worker_id = base_id; worker_id < base_id + num_workers; ++worker_id)
for(WorkerId worker_id = base_id; worker_id < base_id + num_workers; ++worker_id)
{
WorkerId pu_id = worker_id % TaskFreeCtx::n_pus;
// allocate worker with id `i` on arena `i`,
Expand Down
2 changes: 1 addition & 1 deletion redGrapes/redGrapes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ namespace redGrapes
}

template<C_TaskProperty... UserTaskProps>
[[nodiscard]] inline auto init(size_t n_workers = std::thread::hardware_concurrency())
[[nodiscard]] inline auto init(WorkerId n_workers = std::thread::hardware_concurrency())
{
auto execDesc = SchedulerDescription(
std::make_shared<scheduler::PoolScheduler<dispatch::thread::DefaultWorker<Task<UserTaskProps...>>>>(
Expand Down
9 changes: 7 additions & 2 deletions redGrapes/resource/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ namespace redGrapes
AccessPolicy policy;
}; // struct ThisResourceAccess

friend class ResourceBase<TTask>;

std::shared_ptr<ResourceBase<TTask>> base;

Resource(std::shared_ptr<ResourceBase<TTask>> base) : base(base)
Expand All @@ -351,6 +349,13 @@ namespace redGrapes
= redGrapes::memory::alloc_shared_bind<Access>(mapping::map_resource_to_worker(base->id), base, pol);
return ResourceAccess<TTask>(a);
}

ResourceId resource_id() const
{
return base->id;
}


}; // class Resource

template<typename T, typename TTask, typename AccessPolicy>
Expand Down
2 changes: 1 addition & 1 deletion redGrapes/task/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace redGrapes
taken = true;
task.get_result_get_event().notify();

return std::move(result);
return result;
}

/*! check if the result is already computed
Expand Down
27 changes: 19 additions & 8 deletions redGrapes/util/chunked_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,6 @@ namespace redGrapes
*/
uintptr_t cur_item;

inline Item* get_item_ptr() const
{
return (Item*) (cur_item & (~(uintptr_t) 0 >> 1));
}

inline bool has_item() const
{
return cur_item & ~(~(uintptr_t) 0 >> 1);
Expand All @@ -320,6 +315,11 @@ namespace redGrapes
* Only by `rend()`, and if the container is empty also `rbegin()` shall
* return an iterator with invalid idx.
*/
inline Item* get_item_ptr() const
{
return (Item*) (cur_item & (~(uintptr_t) 0 >> 1));
}

bool is_valid_idx() const
{
return ((bool) chunk) && (get_item_ptr() >= chunk->first_item)
Expand Down Expand Up @@ -454,12 +454,23 @@ namespace redGrapes
{
}

inline bool operator!=(BackwardIterator<is_const> const& other) const
BackwardIterator(BackwardIterator<is_const> const& other) : ItemAccess<is_const>(other)
{
}

~BackwardIterator() = default;

friend bool operator==(BackwardIterator<is_const> const& a, BackwardIterator<is_const> const& b)
{
return a.get_item_ptr() == b.get_item_ptr();
}

friend bool operator!=(BackwardIterator<is_const> const& a, BackwardIterator<is_const> const& b)
{
return this->get_item_ptr() != other.get_item_ptr();
return !(a == b);
}

BackwardIterator<is_const>& operator=(BackwardIterator<is_const> const& other)
BackwardIterator& operator=(BackwardIterator<is_const> const& other)
{
this->release();
this->cur_item = (uintptr_t) other.get_item_ptr();
Expand Down
Loading