Commit c42ab2ad authored by kolusask's avatar kolusask
Browse files

Use ParallelFor in Value class

parent 84a5d332
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
#pragma once

#include <TNL/Algorithms/ParallelFor.h>
#include <TNL/Containers/Array.h>

#include <memory>
@@ -18,8 +19,14 @@ struct Value {
    static TNL::Containers::Array<Value<T>, Device> fill(const Array<T, Device>& values) {
        TNL::Containers::Array<Value<T>, Device> arr;
        arr.setSize(values.getSize());
        for (int i = 0; i < values.getSize(); i++)
            arr[i] = Value(values[i]);

        //for (int i = 0; i < values.getSize(); i++)
        auto aView = arr.getView();
        auto vView = values.getConstView();
        auto _fill = [aView, vView] __cuda_callable__ (int i) mutable {
            aView[i] = Value(vView[i]);
        };
        TNL::Algorithms::ParallelFor<Device>::exec(0, values.getSize(), _fill);
        return std::move(arr);
    }