Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
BlockVectorWriterT.h
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19#pragma once
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24#include <arccore/message_passing/Messages.h>
25
27#include <alien/kernels/simple_csr/SimpleCSRVector.h>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38namespace Common
39{
40
41 /*---------------------------------------------------------------------------*/
42 /*---------------------------------------------------------------------------*/
43
44 template <typename ValueT>
45 BlockVectorWriterBaseT<ValueT>::BlockVectorWriterBaseT(IVector& vector)
46 : m_vector(vector)
47 , m_vector_impl(nullptr)
48 , m_block(vector.impl()->block()) // Exception si mauvais kind
49 , m_vblock(vector.impl()->vblock())
50 , m_finalized(false)
51 , m_changed(false)
52 {
53 using namespace Alien;
55 m_vector.impl()->template get<BackEnd::tag::simplecsr>(false);
56 m_values = v.fullValues();
57 m_vector_impl = &v;
58 }
59
60 /*---------------------------------------------------------------------------*/
61
62 template <typename ValueT>
63 LocalBlockVectorWriterT<ValueT>::LocalBlockVectorWriterT(IVector& vector)
64 : BlockVectorWriterBaseT<ValueT>(vector)
65 {}
66
67 /*---------------------------------------------------------------------------*/
68
69 template <typename ValueT>
70 void BlockVectorWriterBaseT<ValueT>::end()
71 {
72 IMessagePassingMng* parallelMng = m_vector_impl->distribution().parallelMng();
73 m_changed = Arccore::MessagePassing::mpAllReduce(
74 parallelMng, Arccore::MessagePassing::ReduceMax, m_changed);
75 if (m_finalized or not m_changed)
76 return;
77 m_finalized = true;
78 m_vector_impl->updateTimestamp();
79 }
80
81 /*---------------------------------------------------------------------------*/
82
83 template <typename ValueT>
84 BlockVectorWriterBaseT<ValueT>& BlockVectorWriterBaseT<ValueT>::operator=(
85 const ValueT v)
86 {
87 m_values.fill(v);
88 return *this;
89 }
90
91 /*---------------------------------------------------------------------------*/
92
93 template <typename ValueT>
94 BlockVectorWriterT<ValueT>::BlockVectorWriterT(IVector& vector)
95 : BlockVectorWriterBaseT<ValueT>(vector)
96 , m_local_offset(0) // On ne peut plus utiliser vector!!
97 {
98 using Base = BlockVectorWriterBaseT<ValueT>;
99 m_local_offset = Base::m_vector.impl()->distribution().offset();
100 }
101
102 /*---------------------------------------------------------------------------*/
103 /*---------------------------------------------------------------------------*/
104} // namespace Common
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109} // namespace Alien
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
MultiVectorImpl.h.
Interface for all vectors.
Definition IVector.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17