Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
BasicSerializer.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* BasicSerializer.cc (C) 2000-2024 */
9/* */
10/* Implémentation simple de 'ISerializer'. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/serialize/BasicSerializer.h"
15#include "arccore/serialize/BasicSerializerInternal.h"
16
17#include "arccore/base/ArgumentException.h"
18#include "arccore/base/FatalErrorException.h"
19
20#include <iostream>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arccore
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
48: public BasicSerializer::Impl
49{
51 static constexpr int IDX_TAG = 0;
53 static constexpr Int64 SERIALIZE_TAG = 0x7a9b3cd0;
55 static constexpr int IDX_VERSION = 1;
57 static constexpr int IDX_RESERVED1 = 2;
58
60 static constexpr int IDX_TOTAL_SIZE = 3;
61
62 static constexpr int IDX_NB_BYTE = 4;
63 static constexpr int IDX_NB_FLOAT16 = 5;
64 static constexpr int IDX_NB_FLOAT32 = 6;
65 static constexpr int IDX_NB_FLOAT64 = 7;
66 static constexpr int IDX_NB_FLOAT128 = 8;
67 static constexpr int IDX_NB_INT16 = 9;
68 static constexpr int IDX_NB_INT32 = 10;
69 static constexpr int IDX_NB_INT64 = 11;
70 static constexpr int IDX_NB_INT128 = 12;
71 static constexpr int IDX_NB_INT8 = 13;
72 static constexpr int IDX_NB_BFLOAT16 = 14;
73
74 // Laisse de la place pour de nouveaux types.
75 static constexpr int IDX_POS_BYTE = 32;
76 static constexpr int IDX_POS_FLOAT16 = 33;
77 static constexpr int IDX_POS_FLOAT32 = 34;
78 static constexpr int IDX_POS_FLOAT64 = 35;
79 static constexpr int IDX_POS_FLOAT128 = 36;
80 static constexpr int IDX_POS_INT16 = 37;
81 static constexpr int IDX_POS_INT32 = 38;
82 static constexpr int IDX_POS_INT64 = 39;
83 static constexpr int IDX_POS_INT128 = 40;
84 static constexpr int IDX_POS_INT8 = 41;
85 static constexpr int IDX_POS_BFLOAT16 = 42;
86
87 static constexpr Integer NB_SIZE_ELEM = 128;
88 // La taille de l'alignement est aussi un diviseur de la mémoire
89 // allouée pour le message. Elle ne doit pas être modifiée sans modifier
90 // la gestion MPI de la sérialisation.
91 static constexpr Integer ALIGN_SIZE = BasicSerializer::paddingSize();
92
93 public:
94
96 struct SizeInfo
97 {
98 public:
99 Int64 m_original_size = 0;
100 Int64 m_padded_size = 0;
101 };
102
103 public:
104
107
110
120
122
130
131 public:
132 Span<Real> getRealBuffer() override { return m_real_view; }
133 Span<Int16> getInt16Buffer() override { return m_int16_view; }
134 Span<Int32> getInt32Buffer() override { return m_int32_view; }
135 Span<Int64> getInt64Buffer() override { return m_int64_view; }
136 Span<Byte> getByteBuffer() override { return m_byte_view; }
137 Span<Int8> getInt8Buffer() override { return m_int8_view; }
138 Span<Float16> getFloat16Buffer() override { return m_float16_view; }
139 Span<BFloat16> getBFloat16Buffer() override { return m_bfloat16_view; }
140 Span<Float32> getFloat32Buffer() override { return m_float32_view; }
141
142 void allocateBuffer(Int64 nb_real,Int64 nb_int16,Int64 nb_int32,
143 Int64 nb_int64,Int64 nb_byte) override
144 {
145 Int64 nb_int8= 0;
146 Int64 nb_float16 = 0;
147 Int64 nb_bfloat16 = 0;
148 Int64 nb_float32 = 0;
149 allocateBuffer(nb_real,nb_int16,nb_int32,nb_int64,nb_byte,nb_int8,nb_float16,nb_bfloat16,nb_float32);
150 }
151
152 void allocateBuffer(Int64 nb_real, Int64 nb_int16, Int64 nb_int32,
153 Int64 nb_int64, Int64 nb_byte, Int64 nb_int8, Int64 nb_float16,
154 Int64 nb_bfloat16, Int64 nb_float32) override
155 {
156 SizeInfo size_info = getPaddingSize(NB_SIZE_ELEM,sizeof(Int64));
157 Int64 total = size_info.m_padded_size;
158
159 Int64 real_position = total;
160 SizeInfo padded_real_size = getPaddingSize(nb_real,sizeof(Real));
161 total += padded_real_size.m_padded_size;
162
163 Int64 int16_position = total;
164 SizeInfo padded_int16_size = getPaddingSize(nb_int16,sizeof(Int16));
165 total += padded_int16_size.m_padded_size;
166
167 Int64 int32_position = total;
168 SizeInfo padded_int32_size = getPaddingSize(nb_int32,sizeof(Int32));
169 total += padded_int32_size.m_padded_size;
170
171 Int64 int64_position = total;
172 SizeInfo padded_int64_size = getPaddingSize(nb_int64,sizeof(Int64));
173 total += padded_int64_size.m_padded_size;
174
175 Int64 byte_position = total;
176 SizeInfo padded_byte_size = getPaddingSize(nb_byte,sizeof(Byte));
177 total += padded_byte_size.m_padded_size;
178
179 Int64 int8_position = total;
180 SizeInfo padded_int8_size = getPaddingSize(nb_int8,sizeof(Int8));
181 total += padded_int8_size.m_padded_size;
182
183 Int64 float16_position = total;
184 SizeInfo padded_float16_size = getPaddingSize(nb_float16,sizeof(Float16));
185 total += padded_float16_size.m_padded_size;
186
187 Int64 bfloat16_position = total;
188 SizeInfo padded_bfloat16_size = getPaddingSize(nb_bfloat16,sizeof(BFloat16));
189 total += padded_bfloat16_size.m_padded_size;
190
191 Int64 float32_position = total;
192 SizeInfo padded_float32_size = getPaddingSize(nb_float32,sizeof(Float32));
193 total += padded_float32_size.m_padded_size;
194
195 _allocBuffer(total);
196
197 _fillPadding(0,size_info);
198 _fillPadding(real_position,padded_real_size);
199 _fillPadding(int16_position,padded_int16_size);
200 _fillPadding(int32_position,padded_int32_size);
201 _fillPadding(int64_position,padded_int64_size);
202 _fillPadding(byte_position,padded_byte_size);
203 _fillPadding(int8_position,padded_int8_size);
204 _fillPadding(float16_position,padded_float16_size);
205 _fillPadding(bfloat16_position,padded_bfloat16_size);
206 _fillPadding(float32_position,padded_float32_size);
207
208 m_sizes_view = Int64ArrayView(NB_SIZE_ELEM,(Int64*)&m_buffer_view[0]);
210
214
216 m_sizes_view[IDX_NB_FLOAT64] = nb_real;
217 m_sizes_view[IDX_NB_INT64] = nb_int64;
218 m_sizes_view[IDX_NB_INT32] = nb_int32;
219 m_sizes_view[IDX_NB_INT16] = nb_int16;
220 m_sizes_view[IDX_NB_BYTE] = nb_byte;
221 m_sizes_view[IDX_NB_INT8] = nb_int8;
222 m_sizes_view[IDX_NB_FLOAT16] = nb_float16;
223 m_sizes_view[IDX_NB_BFLOAT16] = nb_bfloat16;
224 m_sizes_view[IDX_NB_FLOAT32] = nb_float32;
225
226 m_sizes_view[IDX_POS_FLOAT64] = real_position;
227 m_sizes_view[IDX_POS_INT64] = int64_position;
228 m_sizes_view[IDX_POS_INT32] = int32_position;
229 m_sizes_view[IDX_POS_INT16] = int16_position;
230 m_sizes_view[IDX_POS_BYTE] = byte_position;
231 m_sizes_view[IDX_POS_INT8] = int8_position;
232 m_sizes_view[IDX_POS_FLOAT16] = float16_position;
233 m_sizes_view[IDX_POS_BFLOAT16] = bfloat16_position;
234 m_sizes_view[IDX_POS_FLOAT32] = float32_position;
235
236 m_real_view = Span<Real>((Real*)&m_buffer_view[real_position],nb_real);
237 m_int16_view = Span<Int16>((Int16*)&m_buffer_view[int16_position],nb_int16);
238 m_int32_view = Span<Int32>((Int32*)&m_buffer_view[int32_position],nb_int32);
239 m_int64_view = Span<Int64>((Int64*)&m_buffer_view[int64_position],nb_int64);
240 m_byte_view = Span<Byte>((Byte*)&m_buffer_view[byte_position],nb_byte);
241 m_int8_view = Span<Int8>((Int8*)&m_buffer_view[int8_position],nb_int8);
242 m_float16_view = Span<Float16>((Float16*)&m_buffer_view[float16_position],nb_float16);
243 m_bfloat16_view = Span<BFloat16>((BFloat16*)&m_buffer_view[bfloat16_position],nb_bfloat16);
244 m_float32_view = Span<Float32>((Float32*)&m_buffer_view[float32_position],nb_float32);
245
246 _checkAlignment();
247 }
248
249 void copy(Impl* rhs) override
250 {
251 m_real_view.copy(rhs->getRealBuffer());
252 m_int64_view.copy(rhs->getInt64Buffer());
253 m_int32_view.copy(rhs->getInt32Buffer());
254 m_int16_view.copy(rhs->getInt16Buffer());
255 m_byte_view.copy(rhs->getByteBuffer());
256 m_int8_view.copy(rhs->getInt8Buffer());
257 m_float16_view.copy(rhs->getFloat16Buffer());
258 m_bfloat16_view.copy(rhs->getBFloat16Buffer());
259 m_float32_view.copy(rhs->getFloat32Buffer());
260
261 _checkAlignment();
262 }
263
264 Span<Byte> globalBuffer() override
265 {
266 return m_buffer_view;
267 }
268
269 Span<const Byte> globalBuffer() const override
270 {
271 return m_buffer_view;
272 }
273
274 Int64ConstArrayView sizesBuffer() const override
275 {
276 return m_sizes_view;
277 }
278
279 void preallocate(Int64 size) override
280 {
281 _allocBuffer(size);
282 m_sizes_view = Int64ArrayView(NB_SIZE_ELEM,(Int64*)&m_buffer_view[0]);
283 }
284
285 void releaseBuffer() override
286 {
288 }
289
290 void setFromSizes() override
291 {
292 Int64 tag_id = m_sizes_view[IDX_TAG];
293 if (tag_id!=SERIALIZE_TAG)
294 ARCCORE_FATAL("Bad tag id '{0}' for serializer (expected={1})."
295 "The data are not from a BasicSerializer. SizeView={2}",
297 Int64 version_id = m_sizes_view[IDX_VERSION];
298 if (version_id!=1)
299 ARCCORE_FATAL("Bad version '{0}' for serializer. Only version 1 is allowed",version_id);
300
301 Int64 nb_real = m_sizes_view[IDX_NB_FLOAT64];
302 Int64 nb_int64 = m_sizes_view[IDX_NB_INT64];
303 Int64 nb_int32 = m_sizes_view[IDX_NB_INT32];
304 Int64 nb_int16 = m_sizes_view[IDX_NB_INT16];
305 Int64 nb_byte = m_sizes_view[IDX_NB_BYTE];
306 Int64 nb_int8 = m_sizes_view[IDX_NB_INT8];
307 Int64 nb_float16 = m_sizes_view[IDX_NB_FLOAT16];
308 Int64 nb_bfloat16 = m_sizes_view[IDX_NB_BFLOAT16];
309 Int64 nb_float32 = m_sizes_view[IDX_NB_FLOAT32];
310
311 Int64 real_position = m_sizes_view[IDX_POS_FLOAT64];
312 Int64 int64_position = m_sizes_view[IDX_POS_INT64];
313 Int64 int32_position = m_sizes_view[IDX_POS_INT32];
314 Int64 int16_position = m_sizes_view[IDX_POS_INT16];
315 Int64 byte_position = m_sizes_view[IDX_POS_BYTE];
316 Int64 int8_position = m_sizes_view[IDX_POS_INT8];
317 Int64 float16_position = m_sizes_view[IDX_POS_FLOAT16];
318 Int64 bfloat16_position = m_sizes_view[IDX_POS_BFLOAT16];
319 Int64 float32_position = m_sizes_view[IDX_POS_FLOAT32];
320
321 m_real_view = Span<Real>((Real*)&m_buffer_view[real_position],nb_real);
322 m_int16_view = Span<Int16>((Int16*)&m_buffer_view[int16_position],nb_int16);
323 m_int32_view = Span<Int32>((Int32*)&m_buffer_view[int32_position],nb_int32);
324 m_int64_view = Span<Int64>((Int64*)&m_buffer_view[int64_position],nb_int64);
325 m_byte_view = Span<Byte>((Byte*)&m_buffer_view[byte_position],nb_byte);
326 m_int8_view = Span<Int8>((Int8*)&m_buffer_view[int8_position],nb_int8);
327 m_float16_view = Span<Float16>((Float16*)&m_buffer_view[float16_position],nb_float16);
328 m_bfloat16_view = Span<BFloat16>((BFloat16*)&m_buffer_view[bfloat16_position],nb_bfloat16);
329 m_float32_view = Span<Float32>((Float32*)&m_buffer_view[float32_position],nb_float32);
330
331 _checkAlignment();
332 }
333
334 ByteConstArrayView copyAndGetSizesBuffer() override
335 {
336 // Recopie dans \a m_size_copy_buffer les valeurs de \a m_size_view
337 // et retourne un pointeur sur \a m_size_copy_buffer.
338 Int64ArrayView copy_buf(NB_SIZE_ELEM,m_size_copy_buffer);
339 copy_buf.copy(m_sizes_view);
341 return bytes;
342 }
343
344 Int64 totalSize() const override
345 {
347 }
348
349 void printSizes(std::ostream& o) const override
350 {
351 Int64ConstArrayView sbuf_sizes = this->sizesBuffer();
352 Int64 total_size = totalSize();
353 Span<Byte> bytes = m_buffer_view;
354 o << " bytes " << bytes.size()
355 << " total_size " << total_size
356 << " float64 " << sbuf_sizes[IDX_NB_FLOAT64]
357 << " int64 " << sbuf_sizes[IDX_NB_INT64]
358 << " int32 " << sbuf_sizes[IDX_NB_INT32]
359 << " int16 " << sbuf_sizes[IDX_NB_INT16]
360 << " byte " << sbuf_sizes[IDX_NB_BYTE]
361 << " int8 " << sbuf_sizes[IDX_NB_INT8]
362 << " float16 " << sbuf_sizes[IDX_NB_FLOAT16]
363 << " bfloat16 " << sbuf_sizes[IDX_NB_BFLOAT16]
364 << " float32 " << sbuf_sizes[IDX_NB_FLOAT32]
365 << " ptr=" << (void*)bytes.data();
366 }
367
368 protected:
369
370 SizeInfo getPaddingSize(Int64 nb_elem,Int64 elem_size)
371 {
372 if (nb_elem<0)
373 ARCCORE_FATAL("Bad number of element '{0}' (should be >=0)",nb_elem);
374 if (elem_size<=0)
375 ARCCORE_FATAL("Bad elem_size '{0}'",elem_size);
376 Int64 s = nb_elem * elem_size;
377 Int64 pad = s % ALIGN_SIZE;
378 if (pad==0)
379 pad = ALIGN_SIZE;
380 Int64 new_size = s + (ALIGN_SIZE-pad);
381 if ( (new_size%ALIGN_SIZE)!=0 )
382 ARCCORE_FATAL("Bad padding {0}",new_size);
383 //std::cout << " nb_elem=" << nb_elem << " elem_size=" << elem_size << " s=" << s << " new_size=" << new_size << '\n';
384 return { s, new_size };
385 }
386
393 void _fillPadding(Int64 position,SizeInfo size_info)
394 {
395 Int64 begin = position + size_info.m_original_size;
396 Int64 end = position + size_info.m_padded_size;
397 _fillPadding(m_buffer_view.subspan(begin,end-begin));
398 }
399
400 void _fillPadding(Span<Byte> buf)
401 {
402 // Utilise une valeur non nulle pour repérer plus facilement
403 // les zones de padding si besoin.
404 constexpr Byte v = (Byte)(250);
405 for( Int64 i=0, s=buf.size(); i<s; ++i )
406 buf[i] = v;
407 }
408
409 void _checkAlignment()
410 {
411 _checkAddr(m_real_view.data());
412 _checkAddr(m_int16_view.data());
413 _checkAddr(m_int32_view.data());
414 _checkAddr(m_int64_view.data());
415 _checkAddr(m_byte_view.data());
416 _checkAddr(m_int8_view.data());
417 _checkAddr(m_float16_view.data());
418 _checkAddr(m_bfloat16_view.data());
419 _checkAddr(m_float32_view.data());
420 }
421
422 void _checkAddr(void* ptr)
423 {
424 Int64 addr = (Int64)ptr;
425 if ((addr%ALIGN_SIZE)!=0){
426 _printAlignment();
427 ARCCORE_FATAL("Bad alignment addr={0} - {1}",addr,(addr % ALIGN_SIZE));
428 }
429 }
430
431 void _printAlignment()
432 {
433 for( Integer i=0, n=m_sizes_view.size(); i<n; ++i )
434 std::cout << " Size i=" << i << " v=" << m_sizes_view[i] << " pad=" << (m_sizes_view[i] % ALIGN_SIZE) << '\n';
435 _printAddr(m_buffer_view.data(),"Buffer");
436 _printAddr(m_real_view.data(),"Real");
437 _printAddr(m_int16_view.data(),"Int16");
438 _printAddr(m_int32_view.data(),"Int32");
439 _printAddr(m_int64_view.data(),"Int64");
440 _printAddr(m_byte_view.data(),"Byte");
441 _printAddr(m_int8_view.data(),"Int8");
442 _printAddr(m_float16_view.data(),"Float16");
443 _printAddr(m_bfloat16_view.data(),"BFloat16");
444 _printAddr(m_float32_view.data(),"Float32");
445 }
446
447 void _printAddr(void* ptr,const String& name)
448 {
449 Int64 addr = (Int64)ptr;
450 std::cout << "Align type=" << name << " addr=" << addr << " offset=" << (addr % ALIGN_SIZE) << '\n';
451 }
452
453 void _allocBuffer(Int64 size)
454 {
455 if (size<1024)
456 size = 1024;
457 m_buffer.resize(size+ALIGN_SIZE*4);
458 Int64 addr = (Int64)(&m_buffer[0]);
459 Int64 padding = addr % ALIGN_SIZE;
460 Int64 position = 0;
461 if (padding!=0){
462 position = ALIGN_SIZE - padding;
463 }
464 // La taille doit être un multiple de ALIGN_SIZE;
465 Int64 new_size = (size + ALIGN_SIZE) - (size%ALIGN_SIZE);
466 m_buffer_view = m_buffer.span().subspan(position,new_size);
467
468 // Initialise les valeurs de la zone tampon
469 auto padding_view = m_buffer.span().subspan(position+size,new_size-size);
470 _fillPadding(padding_view);
471 }
472};
473
474/*---------------------------------------------------------------------------*/
475/*---------------------------------------------------------------------------*/
476
477/*---------------------------------------------------------------------------*/
478/*---------------------------------------------------------------------------*/
479
480BasicSerializer::Impl2::
481Impl2()
482: m_mode(ModeReserve)
483, m_read_mode(ReadReplace)
484, m_p(new BasicSerializerNewImpl())
485{
486}
487
488/*---------------------------------------------------------------------------*/
489/*---------------------------------------------------------------------------*/
490
491BasicSerializer::Impl2::
492~Impl2()
493{
494 delete m_p;
495}
496
497/*---------------------------------------------------------------------------*/
498/*---------------------------------------------------------------------------*/
499
500void BasicSerializer::Impl2::
501reserve(eDataType dt,Int64 n,Int64 nb_put)
502{
503 ARCCORE_ASSERT((m_mode==ModeReserve),("Bad mode"));
504 switch(dt){
505 case DT_Real: m_real.m_reserved_size += n; break;
506 case DT_Int64: m_int64.m_reserved_size += n; break;
507 case DT_Int32: m_int32.m_reserved_size += n; break;
508 case DT_Int16: m_int16.m_reserved_size += n; break;
509 case DT_Byte: m_byte.m_reserved_size += n; break;
510 case DT_Int8: m_int8.m_reserved_size += n; break;
511 case DT_Float16: m_float16.m_reserved_size += n; break;
512 case DT_BFloat16: m_bfloat16.m_reserved_size += n; break;
513 case DT_Float32: m_float32.m_reserved_size += n; break;
514 default:
515 ARCCORE_THROW(ArgumentException,"bad datatype v={0}",(int)dt);
516 }
517 if (m_is_serialize_typeinfo)
518 // Pour le type de la donnée.
519 m_byte.m_reserved_size += nb_put;
520}
521
522/*---------------------------------------------------------------------------*/
523/*---------------------------------------------------------------------------*/
524
525void BasicSerializer::Impl2::
526putType(eBasicDataType t)
527{
528 if (m_is_serialize_typeinfo){
529 Byte b = static_cast<Byte>(t);
530 m_byte.put(Span<const Byte>(&b, 1));
531 }
532}
533
534/*---------------------------------------------------------------------------*/
535/*---------------------------------------------------------------------------*/
536
537void BasicSerializer::Impl2::
538getAndCheckType(eBasicDataType expected_type)
539{
540 if (!m_is_serialize_typeinfo)
541 return;
542 Byte b = 0;
543 m_byte.get(Span<Byte>(&b,1));
544 eBasicDataType t = static_cast<eBasicDataType>(b);
545 if (t!=expected_type)
546 ARCCORE_FATAL("Bad serialized type t='{0}' int={1}' expected='{2}'",t,(int)t,expected_type);
547}
548
549/*---------------------------------------------------------------------------*/
550/*---------------------------------------------------------------------------*/
551
552void BasicSerializer::Impl2::
553allocateBuffer()
554{
555 m_p->allocateBuffer(m_real.m_reserved_size,m_int16.m_reserved_size,m_int32.m_reserved_size,
556 m_int64.m_reserved_size,m_byte.m_reserved_size,m_int8.m_reserved_size,
557 m_float16.m_reserved_size,m_bfloat16.m_reserved_size,m_float32.m_reserved_size);
558 _setViews();
559}
560
561/*---------------------------------------------------------------------------*/
562/*---------------------------------------------------------------------------*/
563
564void BasicSerializer::Impl2::
565setFromSizes()
566{
567 m_p->setFromSizes();
568 _setViews();
569}
570
571/*---------------------------------------------------------------------------*/
572/*---------------------------------------------------------------------------*/
573
574void BasicSerializer::Impl2::
575_setViews()
576{
577 m_real.m_buffer = m_p->getRealBuffer();
578 m_real.m_current_position = 0;
579
580 m_int64.m_buffer = m_p->getInt64Buffer();
581 m_int64.m_current_position = 0;
582
583 m_int32.m_buffer = m_p->getInt32Buffer();
584 m_int32.m_current_position = 0;
585
586 m_int16.m_buffer = m_p->getInt16Buffer();
587 m_int16.m_current_position = 0;
588
589 m_byte.m_buffer = m_p->getByteBuffer();
590 m_byte.m_current_position = 0;
591
592 m_int8.m_buffer = m_p->getInt8Buffer();
593 m_int8.m_current_position = 0;
594
595 m_float16.m_buffer = m_p->getFloat16Buffer();
596 m_float16.m_current_position = 0;
597
598 m_bfloat16.m_buffer = m_p->getBFloat16Buffer();
599 m_bfloat16.m_current_position = 0;
600
601 m_float32.m_buffer = m_p->getFloat32Buffer();
602 m_float32.m_current_position = 0;
603}
604
605/*---------------------------------------------------------------------------*/
606/*---------------------------------------------------------------------------*/
607
608void BasicSerializer::Impl2::
609allocateBuffer(Int64 nb_real,Int64 nb_int16,Int64 nb_int32,
610 Int64 nb_int64,Int64 nb_byte)
611{
612 Int64 nb_int8= 0;
613 Int64 nb_float16 = 0;
614 Int64 nb_bfloat16 = 0;
615 Int64 nb_float32 = 0;
616 allocateBuffer(nb_real,nb_int16,nb_int32,nb_int64,nb_byte,nb_int8,nb_float16,nb_bfloat16,nb_float32);
617}
618
619/*---------------------------------------------------------------------------*/
620/*---------------------------------------------------------------------------*/
621
622void BasicSerializer::Impl2::
623allocateBuffer(Int64 nb_real,Int64 nb_int16,Int64 nb_int32,
624 Int64 nb_int64,Int64 nb_byte,Int64 nb_int8, Int64 nb_float16,
625 Int64 nb_bfloat16, Int64 nb_float32)
626{
627 m_real.m_reserved_size = nb_real;
628 m_int64.m_reserved_size = nb_int64;
629 m_int32.m_reserved_size = nb_int32;
630 m_int16.m_reserved_size = nb_int16;
631 m_byte.m_reserved_size = nb_byte;
632 m_int8.m_reserved_size = nb_int8;
633 m_float16.m_reserved_size = nb_float16;
634 m_bfloat16.m_reserved_size = nb_bfloat16;
635 m_float32.m_reserved_size = nb_float32;
636 allocateBuffer();
637}
638
639/*---------------------------------------------------------------------------*/
640/*---------------------------------------------------------------------------*/
641
642void BasicSerializer::Impl2::
643copy(const BasicSerializer& rhs)
644{
645 auto rhs_p = rhs._p();
646 Span<Real> real_b = rhs_p->getRealBuffer();
647 Span<Int64> int64_b = rhs_p->getInt64Buffer();
648 Span<Int32> int32_b = rhs_p->getInt32Buffer();
649 Span<Int16> int16_b = rhs_p->getInt16Buffer();
650 Span<Byte> byte_b = rhs_p->getByteBuffer();
651 Span<Int8> int8_b = rhs_p->getInt8Buffer();
652 Span<Float16> float16_b = rhs_p->getFloat16Buffer();
653 Span<BFloat16> bfloat16_b = rhs_p->getBFloat16Buffer();
654 Span<Float32> float32_b = rhs_p->getFloat32Buffer();
655 allocateBuffer(real_b.size(),int16_b.size(),int32_b.size(),int64_b.size(),byte_b.size(),
656 int8_b.size(),float16_b.size(),bfloat16_b.size(),float32_b.size());
657 m_p->copy(rhs_p);
658}
659
660/*---------------------------------------------------------------------------*/
661/*---------------------------------------------------------------------------*/
662
663void BasicSerializer::Impl2::
664setMode(eMode new_mode)
665{
666 if (new_mode==BasicSerializer::ModeGet && new_mode!=m_mode){
667 m_real.m_current_position = 0;
668 m_int64.m_current_position = 0;
669 m_int32.m_current_position = 0;
670 m_int16.m_current_position = 0;
671 m_byte.m_current_position = 0;
672 m_int8.m_current_position = 0;
673 m_float16.m_current_position = 0;
674 m_bfloat16.m_current_position = 0;
675 m_float32.m_current_position = 0;
676 }
677
678 m_mode = new_mode;
679}
680
681/*---------------------------------------------------------------------------*/
682/*---------------------------------------------------------------------------*/
683
684/*---------------------------------------------------------------------------*/
685/*---------------------------------------------------------------------------*/
686
687BasicSerializer::
688BasicSerializer()
689: m_p2(new Impl2())
690{
691}
692
693/*---------------------------------------------------------------------------*/
694/*---------------------------------------------------------------------------*/
695
696BasicSerializer::
697BasicSerializer(const BasicSerializer& sb)
698: m_p2(new Impl2())
699{
700 copy(sb);
701}
702
703/*---------------------------------------------------------------------------*/
704/*---------------------------------------------------------------------------*/
705
706BasicSerializer::
707~BasicSerializer()
708{
709 delete m_p2;
710}
711
712/*---------------------------------------------------------------------------*/
713/*---------------------------------------------------------------------------*/
714
715BasicSerializer::Impl* BasicSerializer::
716_p() const
717{
718 return m_p2->m_p;
719}
720
721/*---------------------------------------------------------------------------*/
722/*---------------------------------------------------------------------------*/
723
724// TODO: rendre ces méthodes privées.
725Span<Real> BasicSerializer::realBuffer() { return m_p2->m_real.m_buffer; }
726Span<Int64> BasicSerializer::int64Buffer() { return m_p2->m_int64.m_buffer; }
727Span<Int32> BasicSerializer::int32Buffer() { return m_p2->m_int32.m_buffer; }
728Span<Int16> BasicSerializer::int16Buffer() { return m_p2->m_int16.m_buffer; }
729Span<Byte> BasicSerializer::byteBuffer() { return m_p2->m_byte.m_buffer; }
730
731/*---------------------------------------------------------------------------*/
732/*---------------------------------------------------------------------------*/
733
736{
737 m_p2->reserve(dt,n,1);
738}
739
740/*---------------------------------------------------------------------------*/
741/*---------------------------------------------------------------------------*/
742
745{
746 m_p2->reserve(dt,n,n);
747}
748
749/*---------------------------------------------------------------------------*/
750/*---------------------------------------------------------------------------*/
751
753reserve(const String& str)
754{
755 reserve(DT_Int64,1);
756 reserveSpan(str.bytes());
757}
758
759/*---------------------------------------------------------------------------*/
760/*---------------------------------------------------------------------------*/
761
764{
765 reserve(DT_Int64,1);
766 reserveSpan(values);
767}
768
771{
772 reserve(DT_Int64,1);
773 reserveSpan(values);
774}
775
778{
779 reserve(DT_Int64,1);
780 reserveSpan(values);
781}
782
785{
786 reserve(DT_Int64,1);
787 reserveSpan(values);
788}
789
792{
793 reserve(DT_Int64,1);
794 reserveSpan(values);
795}
796
799{
800 reserve(DT_Int64,1);
801 reserveSpan(values);
802}
803
806{
807 reserve(DT_Int64,1);
808 reserveSpan(values);
809}
810
813{
814 reserve(DT_Int64,1);
815 reserveSpan(values);
816}
817
820{
821 reserve(DT_Int64,1);
822 reserveSpan(values);
823}
824
825/*---------------------------------------------------------------------------*/
826/*---------------------------------------------------------------------------*/
827
829put(Span<const Real> values)
830{
831 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
832 m_p2->putType(eBasicDataType::Float64);
833 m_p2->m_real.put(values);
834}
835
836/*---------------------------------------------------------------------------*/
837/*---------------------------------------------------------------------------*/
838
841{
842 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
843 m_p2->putType(eBasicDataType::Int64);
844 m_p2->m_int64.put(values);
845}
846
847/*---------------------------------------------------------------------------*/
848/*---------------------------------------------------------------------------*/
849
852{
853 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
854 m_p2->putType(eBasicDataType::Int32);
855 m_p2->m_int32.put(values);
856}
857
858/*---------------------------------------------------------------------------*/
859/*---------------------------------------------------------------------------*/
860
863{
864 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
865 m_p2->putType(eBasicDataType::Int16);
866 m_p2->m_int16.put(values);
867}
868
869/*---------------------------------------------------------------------------*/
870/*---------------------------------------------------------------------------*/
871
873put(Span<const Byte> values)
874{
875 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
876 m_p2->putType(eBasicDataType::Byte);
877 m_p2->m_byte.put(values);
878}
879
880/*---------------------------------------------------------------------------*/
881/*---------------------------------------------------------------------------*/
882
885{
886 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
887 m_p2->putType(eBasicDataType::Int8);
888 m_p2->m_int8.put(values);
889}
890
891/*---------------------------------------------------------------------------*/
892/*---------------------------------------------------------------------------*/
893
896{
897 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
898 m_p2->putType(eBasicDataType::Float16);
899 m_p2->m_float16.put(values);
900}
901
902/*---------------------------------------------------------------------------*/
903/*---------------------------------------------------------------------------*/
904
907{
908 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
909 m_p2->putType(eBasicDataType::BFloat16);
910 m_p2->m_bfloat16.put(values);
911}
912
913/*---------------------------------------------------------------------------*/
914/*---------------------------------------------------------------------------*/
915
918{
919 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
920 m_p2->putType(eBasicDataType::Float32);
921 m_p2->m_float32.put(values);
922}
923
924/*---------------------------------------------------------------------------*/
925/*---------------------------------------------------------------------------*/
926
928put(const String& str)
929{
930 ARCCORE_ASSERT((m_p2->m_mode==ModePut),("Bad mode"));
931 Int64 len = str.length();
932 putInt64(len);
933 putSpan(str.bytes());
934}
935
936/*---------------------------------------------------------------------------*/
937/*---------------------------------------------------------------------------*/
938
941{
942 putInt64(values.size());
943 putSpan(values);
944}
945
948{
949 putInt64(values.size());
950 putSpan(values);
951}
952
955{
956 putInt64(values.size());
957 putSpan(values);
958}
959
962{
963 putInt64(values.size());
964 putSpan(values);
965}
966
969{
970 putInt64(values.size());
971 putSpan(values);
972}
973
976{
977 putInt64(values.size());
978 putSpan(values);
979}
980
983{
984 putInt64(values.size());
985 putSpan(values);
986}
987
990{
991 putInt64(values.size());
992 putSpan(values);
993}
994
997{
998 putInt64(values.size());
999 putSpan(values);
1000}
1001
1002/*---------------------------------------------------------------------------*/
1003/*---------------------------------------------------------------------------*/
1004
1006getSpan(Span<Real> values)
1007{
1008 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1009 m_p2->getAndCheckType(eBasicDataType::Float64);
1010 m_p2->m_real.get(values);
1011}
1012
1013/*---------------------------------------------------------------------------*/
1014/*---------------------------------------------------------------------------*/
1015
1017getSpan(Span<Int64> values)
1018{
1019 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1020 m_p2->getAndCheckType(eBasicDataType::Int64);
1021 m_p2->m_int64.get(values);
1022}
1023
1024/*---------------------------------------------------------------------------*/
1025/*---------------------------------------------------------------------------*/
1026
1028getSpan(Span<Int32> values)
1029{
1030 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1031 m_p2->getAndCheckType(eBasicDataType::Int32);
1032 m_p2->m_int32.get(values);
1033}
1034
1035/*---------------------------------------------------------------------------*/
1036/*---------------------------------------------------------------------------*/
1037
1039getSpan(Span<Int16> values)
1040{
1041 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1042 m_p2->getAndCheckType(eBasicDataType::Int16);
1043 m_p2->m_int16.get(values);
1044}
1045
1046/*---------------------------------------------------------------------------*/
1047/*---------------------------------------------------------------------------*/
1048
1050getSpan(Span<Byte> values)
1051{
1052 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1053 m_p2->getAndCheckType(eBasicDataType::Byte);
1054 m_p2->m_byte.get(values);
1055}
1056
1057/*---------------------------------------------------------------------------*/
1058/*---------------------------------------------------------------------------*/
1059
1061getSpan(Span<Int8> values)
1062{
1063 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1064 m_p2->getAndCheckType(eBasicDataType::Int8);
1065 m_p2->m_int8.get(values);
1066}
1067
1068/*---------------------------------------------------------------------------*/
1069/*---------------------------------------------------------------------------*/
1070
1072getSpan(Span<Float16> values)
1073{
1074 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1075 m_p2->getAndCheckType(eBasicDataType::Float16);
1076 m_p2->m_float16.get(values);
1077}
1078
1079/*---------------------------------------------------------------------------*/
1080/*---------------------------------------------------------------------------*/
1081
1083getSpan(Span<BFloat16> values)
1084{
1085 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1086 m_p2->getAndCheckType(eBasicDataType::BFloat16);
1087 m_p2->m_bfloat16.get(values);
1088}
1089
1090/*---------------------------------------------------------------------------*/
1091/*---------------------------------------------------------------------------*/
1092
1094getSpan(Span<Float32> values)
1095{
1096 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1097 m_p2->getAndCheckType(eBasicDataType::Float32);
1098 m_p2->m_float32.get(values);
1099}
1100
1101/*---------------------------------------------------------------------------*/
1102/*---------------------------------------------------------------------------*/
1103
1105getArray(Array<Real>& values)
1106{
1107 values.resize(getInt64());
1108 getSpan(values);
1109}
1110
1112getArray(Array<Int16>& values)
1113{
1114 values.resize(getInt64());
1115 getSpan(values);
1116}
1117
1119getArray(Array<Int32>& values)
1120{
1121 values.resize(getInt64());
1122 getSpan(values);
1123}
1124
1126getArray(Array<Int64>& values)
1127{
1128 values.resize(getInt64());
1129 getSpan(values);
1130}
1131
1133getArray(Array<Byte>& values)
1134{
1135 values.resize(getInt64());
1136 getSpan(values);
1137}
1138
1140getArray(Array<Int8>& values)
1141{
1142 values.resize(getInt64());
1143 getSpan(values);
1144}
1145
1147getArray(Array<Float16>& values)
1148{
1149 values.resize(getInt64());
1150 getSpan(values);
1151}
1152
1155{
1156 values.resize(getInt64());
1157 getSpan(values);
1158}
1159
1161getArray(Array<Float32>& values)
1162{
1163 values.resize(getInt64());
1164 getSpan(values);
1165}
1166
1167/*---------------------------------------------------------------------------*/
1168/*---------------------------------------------------------------------------*/
1169
1171get(String& str)
1172{
1173 // TODO: il faudrait utiliser des Int64 mais cela casse la compatibilité.
1174 // A étudier.
1175 ARCCORE_ASSERT((m_p2->m_mode==ModeGet),("Bad mode"));
1176 Int64 len = getInt64();
1177 UniqueArray<Byte> bytes(len);
1178 getSpan(bytes);
1179 str = String(bytes.span());
1180}
1181
1182/*---------------------------------------------------------------------------*/
1183/*---------------------------------------------------------------------------*/
1184
1187{
1188 m_p2->allocateBuffer();
1189}
1190
1191/*---------------------------------------------------------------------------*/
1192/*---------------------------------------------------------------------------*/
1193
1195mode() const
1196{
1197 return m_p2->m_mode;
1198}
1199
1200/*---------------------------------------------------------------------------*/
1201/*---------------------------------------------------------------------------*/
1202
1204setMode(eMode new_mode)
1205{
1206 m_p2->setMode(new_mode);
1207}
1208
1209/*---------------------------------------------------------------------------*/
1210/*---------------------------------------------------------------------------*/
1211
1213readMode() const
1214{
1215 return m_p2->m_read_mode;
1216}
1217
1218/*---------------------------------------------------------------------------*/
1219/*---------------------------------------------------------------------------*/
1220
1222setReadMode(eReadMode new_read_mode)
1223{
1224 m_p2->m_read_mode = new_read_mode;
1225}
1226
1227/*---------------------------------------------------------------------------*/
1228/*---------------------------------------------------------------------------*/
1229
1231allocateBuffer(Int64 nb_real,Int64 nb_int16,Int64 nb_int32,
1232 Int64 nb_int64,Int64 nb_byte)
1233{
1234 m_p2->allocateBuffer(nb_real,nb_int16,nb_int32,nb_int64,nb_byte,0,0,0,0);
1235}
1236
1237/*---------------------------------------------------------------------------*/
1238/*---------------------------------------------------------------------------*/
1239
1241copy(const BasicSerializer& rhs)
1242{
1243 m_p2->copy(rhs);
1244}
1245
1246/*---------------------------------------------------------------------------*/
1247/*---------------------------------------------------------------------------*/
1248
1250copy(const ISerializer* from)
1251{
1252 auto sbuf = dynamic_cast<const BasicSerializer*>(from);
1253 if (!sbuf)
1254 ARCCORE_FATAL("Can only copy from 'BasicSerializer'");
1255 copy(*sbuf);
1256}
1257
1258/*---------------------------------------------------------------------------*/
1259/*---------------------------------------------------------------------------*/
1260
1261Span<Byte> BasicSerializer::
1262globalBuffer()
1263{
1264 return _p()->globalBuffer();
1265}
1266
1267/*---------------------------------------------------------------------------*/
1268/*---------------------------------------------------------------------------*/
1269
1270Span<const Byte> BasicSerializer::
1271globalBuffer() const
1272{
1273 return _p()->globalBuffer();
1274}
1275
1276/*---------------------------------------------------------------------------*/
1277/*---------------------------------------------------------------------------*/
1278
1279ByteConstArrayView BasicSerializer::
1280copyAndGetSizesBuffer()
1281{
1282 return _p()->copyAndGetSizesBuffer();
1283}
1284
1285/*---------------------------------------------------------------------------*/
1286/*---------------------------------------------------------------------------*/
1287
1288Int64ConstArrayView BasicSerializer::
1289sizesBuffer()
1290{
1291 return _p()->sizesBuffer();
1292}
1293
1294/*---------------------------------------------------------------------------*/
1295/*---------------------------------------------------------------------------*/
1296
1297void BasicSerializer::
1298preallocate(Int64 size)
1299{
1300 return _p()->preallocate(size);
1301}
1302
1303/*---------------------------------------------------------------------------*/
1304/*---------------------------------------------------------------------------*/
1305
1306void BasicSerializer::
1307releaseBuffer()
1308{
1309 _p()->releaseBuffer();
1310}
1311
1312/*---------------------------------------------------------------------------*/
1313/*---------------------------------------------------------------------------*/
1314
1315void BasicSerializer::
1316setFromSizes()
1317{
1318 m_p2->setFromSizes();
1319}
1320
1321/*---------------------------------------------------------------------------*/
1322/*---------------------------------------------------------------------------*/
1323
1324Int64 BasicSerializer::
1325totalSize() const
1326{
1327 return _p()->totalSize();
1328}
1329
1330/*---------------------------------------------------------------------------*/
1331/*---------------------------------------------------------------------------*/
1332
1333void BasicSerializer::
1334printSizes(std::ostream& o) const
1335{
1336 _p()->printSizes(o);
1337}
1338
1339/*---------------------------------------------------------------------------*/
1340/*---------------------------------------------------------------------------*/
1341
1344{
1345 Int64 nb_byte = buf.size();
1347 preallocate(nb_byte);
1348 globalBuffer().copy(buf);
1349 setFromSizes();
1350}
1351
1352/*---------------------------------------------------------------------------*/
1353/*---------------------------------------------------------------------------*/
1354
1357{
1358 m_p2->setSerializeTypeInfo(v);
1359}
1360
1361/*---------------------------------------------------------------------------*/
1362/*---------------------------------------------------------------------------*/
1363
1364bool BasicSerializer::
1365isSerializeTypeInfo() const
1366{
1367 return m_p2->isSerializeTypeInfo();
1368}
1369
1370/*---------------------------------------------------------------------------*/
1371/*---------------------------------------------------------------------------*/
1372
1373} // End namespace Arccore
1374
1375/*---------------------------------------------------------------------------*/
1376/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
void dispose()
Libère la mémoire utilisée par le tableau.
void fill(const T &o) noexcept
Remplit le tableau avec la valeur o.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
Classe de base des vecteurs 1D de données.
Span< const T > span() const
Vue immutable sur ce tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
Implémentation d'un buffer de sérialisation contigu en mémoire.
static constexpr Int64 SERIALIZE_TAG
Tag identifiant la sérialisation.
UniqueArray< Byte > m_buffer
Tableau contenant les données sérialisées.
Span< Int32 > m_int32_view
Vue sur les entiers 32 bits.
Span< Int16 > m_int16_view
Vue sur les entiers 16 bits.
void _fillPadding(Int64 position, SizeInfo size_info)
Remplit avec une valeur fixe les zones correspondantes au padding. Cela permet d'éviter d'avoir des v...
Int64 m_size_copy_buffer[NB_SIZE_ELEM]
Copie des tailles utilisée pour l'envoie en plusieurs fois.
Span< Byte > m_byte_view
Vur les octets.
static constexpr int IDX_RESERVED1
Champ réservé pour des informations supplémentaires (par exemple compression)
Span< Byte > m_buffer_view
Vue alignée sur ALIGN_SIZE du m_buffer.
Span< Float32 > m_float32_view
Vur les Float32.
Span< Int8 > m_int8_view
Vur les Int8.
Span< BFloat16 > m_bfloat16_view
Vur les BFloat16.
Span< Float16 > m_float16_view
Vur les Float16.
Span< Int64 > m_int64_view
Vue sur les entiers 64 bits.
Int64ArrayView m_sizes_view
Vue pour les tailles (doit être un multiple de ALIGN_SIZE);.
static constexpr int IDX_TAG
Index du tag pour identifier qu'il s'agit d'une sérialisation.
static constexpr int IDX_VERSION
Version de la sérialisation.
Span< Real > m_real_view
Vue sur les reels;.
static constexpr int IDX_TOTAL_SIZE
Position du champs indiquant la taille totale de la sérialisation.
Implémentation basique de 'ISerializer'.
void allocateBuffer() override
Alloue la mémoire du sérialiseur.
Int64 getInt64() override
Récupère une taille.
void getArray(Array< Real > &values) override
Redimensionne et remplit values.
void setReadMode(eReadMode new_read_mode) override
Positionne le mode de lecture.
void copy(const ISerializer *from) override
Copie les données de from dans cette instance.
void reserve(eDataType dt, Int64 n) override
Réserve de la mémoire pour n objets de type dt.
void initFromBuffer(Span< const Byte > buf)
Initialise le sérialiseur en lecture à partir des données buf.
void putSpan(Span< const Int8 > values) override
Ajoute le tableau values.
void put(Span< const Real > values) override
Ajoute le tableau values.
void setMode(eMode new_mode) override
Positionne le fonctionnement actuel.
void setSerializeTypeInfo(bool v)
Indique si on sérialise le type de donnée pour garantir la cohérence.
void putInt64(Int64 value) override
Ajoute l'entier value.
void reserveArray(Span< const Real > values) override
Réserve pour sauver le nombre d'éléments et les values éléments.
static ARCCORE_CONSTEXPR Integer paddingSize()
Taille du padding et de l'alignement.
void getSpan(Span< Real > values) override
Récupère le tableau values.
eMode mode() const override
Mode de fonctionnement actuel.
void get(RealArrayView values) override
Récupère le tableau values.
void reserveSpan(eDataType dt, Int64 n) override
Réserve de la mémoire pour n valeurs de dt.
eReadMode readMode() const override
Mode de lecture.
void putArray(Span< const Real > values) override
Sauve le nombre d'éléments et les values éléments.
ARCCORE_HOST_DEVICE void copy(const U &copy_array)
Recopie le tableau copy_array dans l'instance.
Definition Span.h:357
constexpr ARCCORE_HOST_DEVICE pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:419
constexpr ARCCORE_HOST_DEVICE SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:209
Vue d'un tableau d'éléments de type T.
Definition Span.h:510
constexpr ARCCORE_HOST_DEVICE Span< T, DynExtent > subspan(Int64 abegin, Int64 asize) const
Sous-vue à partir de l'élément abegin et contenant asize éléments.
Definition Span.h:590
Chaîne de caractères unicode.
Span< const Byte > bytes() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Definition String.cc:291
Int64 length() const
Retourne la longueur de la chaîne.
Definition String.cc:338
Vecteur 1D de données avec sémantique par valeur (style STL).
@ DT_Float32
Donnée de type 'Float32'.
Definition DataTypes.h:52
@ DT_Int16
Donnée de type entier 16 bits.
Definition DataTypes.h:42
@ DT_Int8
Donnée de type entier sur 8 bits.
Definition DataTypes.h:53
@ DT_Int32
Donnée de type entier 32 bits.
Definition DataTypes.h:43
@ DT_Float16
Donnée de type 'Float16'.
Definition DataTypes.h:51
@ DT_Int64
Donnée de type entier 64 bits.
Definition DataTypes.h:44
@ DT_BFloat16
Donnée de type 'BFloat16'.
Definition DataTypes.h:50
@ DT_Real
Donnée de type réel.
Definition DataTypes.h:41
@ DT_Byte
Donnée de type octet.
Definition DataTypes.h:40
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
Int32 Integer
Type représentant un entier.
float Float32
Type flottant IEEE-753 simple précision.
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition BaseTypes.h:121
eBasicDataType
Type d'une donnée de base.
@ Float32
Donnée de type Float32.
@ Float16
Donnée de type Float16.
@ Int16
Donnée de type entier 16 bits.
@ Int8
< Donnée de type BFloat16
@ Byte
Donnée de type octet.
@ Int32
Donnée de type entier 32 bits.
@ Float64
Donnée de type Float64.
@ Int64
Donnée de type entier 64 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
Definition BaseTypes.h:138
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition BaseTypes.h:142
std::int8_t Int8
Type entier signé sur 8 bits.
unsigned char Byte
Type d'un octet.
Definition BaseTypes.h:43
Informations sur la taille allouée avec et sans padding.