.\" .de Id .. .de Sp .if n .sp .if t .sp 0.4 .. .TH hack_array 7rheolef "rheolef-6.5" "rheolef-6.5" "rheolef-6.5" .\" label: /*Class:hack_array .SH NAME hack_array - container in distributed environment (rheolef-6.5) .SH SYNOPSYS STL-like vector container for a distributed memory machine model. Contrarily to array, here T can have a size only known at compile time. This class is used when T is a geo_element raw class, i.e. T=geo_element_e_raw. The size of the geo_element depends upon the oder and is known only at run-time. For efficiency purpose, the hack_array allocate all geo_elements of the same variant (e.g. edge) and order in a contiguous area, since the coreesponding element size is constant. .SH EXAMPLE A sample usage of the class is: .\" begin_example .Sp .nf std::pair param (reference_element::t, 3); // triangle, order=3 hack_array x (distributor(100), param); .Sp .fi .\" end_example The hack_array interface is similar to those of the array one. .PP .SH OBJECT REQUIREMENT There are many pre-requises for the template objet type T: .\" begin_example .Sp .nf class T : public T::generic_type { typedef variant_type; typedef raw_type; typedef genetic_type; typedef automatic_type; static const variant_type _variant; static size_t _data_size(const parameter_type& param); static size_t _value_size(const parameter_type& param); }; class T::automatic_type : public T::generic_type { automatic_type (const parameter_type& param); }; class T::generic_type { typedef raw_type; typedef iterator; typedef const_iterator; iterator _data_begin(); const_iterator _data_begin() const; }; ostream& operator<< (ostream&, const T::generic_type&); .Sp .fi .\" end_example .\" skip start:AUTHOR: .\" END .SH IMPLEMENTATION .\" begin_example .Sp .nf template class hack_array : public smart_pointer > { public: // typedefs: typedef hack_array_seq_rep rep; typedef smart_pointer base; typedef sequential memory_type; typedef typename rep::size_type size_type; typedef typename rep::value_type value_type; typedef typename rep::reference reference; typedef typename rep::dis_reference dis_reference; typedef typename rep::iterator iterator; typedef typename rep::const_reference const_reference; typedef typename rep::const_iterator const_iterator; typedef typename rep::parameter_type parameter_type; // allocators: hack_array (const A& alloc = A()); hack_array (size_type loc_size, const parameter_type& param, const A& alloc = A()); void resize (const distributor& ownership, const parameter_type& param); hack_array (const distributor& ownership, const parameter_type& param, const A& alloc = A()); void resize (size_type loc_size, const parameter_type& param); // local accessors & modifiers: A get_allocator() const { return base::data().get_allocator(); } size_type size () const { return base::data().size(); } size_type dis_size () const { return base::data().dis_size(); } const distributor& ownership() const { return base::data().ownership(); } const communicator& comm() const { return ownership().comm(); } reference operator[] (size_type i) { return base::data().operator[] (i); } const_reference operator[] (size_type i) const { return base::data().operator[] (i); } const_reference dis_at (size_type dis_i) const { return base::data().operator[] (dis_i); } iterator begin() { return base::data().begin(); } const_iterator begin() const { return base::data().begin(); } iterator end() { return base::data().end(); } const_iterator end() const { return base::data().end(); } // global accessors (for compatibility with distributed interface): template void append_dis_indexes (const Set& ext_idx_set) const {} void update_dis_entries() const {} // global modifiers (for compatibility with distributed interface): dis_reference dis_entry (size_type dis_i) { return operator[] (dis_i); } void dis_entry_assembly() {} template void dis_entry_assembly(SetOp my_set_op) {} template void dis_entry_assembly_begin (SetOp my_set_op) {} template void dis_entry_assembly_end (SetOp my_set_op) {} // apply a partition: #ifdef TODO template void repartition ( // old_numbering for *this const RepSize& partition, // old_ownership hack_array& new_array, // new_ownership (created) RepSize& old_numbering, // new_ownership RepSize& new_numbering) const // old_ownership { return base::data().repartition (partition, new_array, old_numbering, new_numbering); } template void permutation_apply ( // old_numbering for *this const RepSize& new_numbering, // old_ownership hack_array& new_array) const // new_ownership (already allocated) { return base::data().permutation_apply (new_numbering, new_array); } #endif // TODO // i/o: odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); } idiststream& get_values (idiststream& ips) { return base::data().get_values(ips); } template idiststream& get_values (idiststream& ips, GetFunction get_element) { return base::data().get_values(ips, get_element); } template odiststream& put_values (odiststream& ops, PutFunction put_element) const { return base::data().put_values(ops, put_element); } #ifdef TODO void dump (std::string name) const { return base::data().dump(name); } #endif // TODO }; .Sp .fi .\" end_example .SH IMPLEMENTATION .\" begin_example .Sp .nf template class hack_array : public smart_pointer > { public: // typedefs: typedef hack_array_mpi_rep rep; typedef smart_pointer base; typedef distributed memory_type; typedef typename rep::size_type size_type; typedef typename rep::value_type value_type; typedef typename rep::reference reference; typedef typename rep::dis_reference dis_reference; typedef typename rep::iterator iterator; typedef typename rep::parameter_type parameter_type; typedef typename rep::const_reference const_reference; typedef typename rep::const_iterator const_iterator; typedef typename rep::scatter_map_type scatter_map_type; // allocators: hack_array (const A& alloc = A()); hack_array (const distributor& ownership, const parameter_type& param, const A& alloc = A()); void resize (const distributor& ownership, const parameter_type& param); // local accessors & modifiers: A get_allocator() const { return base::data().get_allocator(); } size_type size () const { return base::data().size(); } size_type dis_size () const { return base::data().dis_size(); } const distributor& ownership() const { return base::data().ownership(); } const communicator& comm() const { return base::data().comm(); } reference operator[] (size_type i) { return base::data().operator[] (i); } const_reference operator[] (size_type i) const { return base::data().operator[] (i); } iterator begin() { return base::data().begin(); } const_iterator begin() const { return base::data().begin(); } iterator end() { return base::data().end(); } const_iterator end() const { return base::data().end(); } // global accessor: template void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const { base::data().append_dis_entry (ext_idx_set, ext_idx_map); } template void get_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const { base::data().get_dis_entry (ext_idx_set, ext_idx_map); } template void append_dis_indexes (const Set& ext_idx_set) const { base::data().append_dis_indexes (ext_idx_set); } template void set_dis_indexes (const Set& ext_idx_set) { base::data().set_dis_indexes (ext_idx_set); } const_reference dis_at (size_type dis_i) const { return base::data().dis_at (dis_i); } // get all external pairs (dis_i, values): const scatter_map_type& get_dis_map_entries() const { return base::data().get_dis_map_entries(); } void update_dis_entries() const { base::data().update_dis_entries(); } // global modifiers (for compatibility with distributed interface): dis_reference dis_entry (size_type dis_i) { return base::data().dis_entry(dis_i); } void dis_entry_assembly() { return base::data().dis_entry_assembly(); } template void dis_entry_assembly (SetOp my_set_op) { return base::data().dis_entry_assembly (my_set_op); } template void dis_entry_assembly_begin (SetOp my_set_op) { return base::data().dis_entry_assembly_begin (my_set_op); } template void dis_entry_assembly_end (SetOp my_set_op) { return base::data().dis_entry_assembly_end (my_set_op); } // apply a partition: template void repartition ( // old_numbering for *this const RepSize& partition, // old_ownership hack_array& new_array, // new_ownership (created) RepSize& old_numbering, // new_ownership RepSize& new_numbering) const // old_ownership { return base::data().repartition (partition.data(), new_array.data(), old_numbering.data(), new_numbering.data()); } #ifdef TODO template void permutation_apply ( // old_numbering for *this const RepSize& new_numbering, // old_ownership hack_array& new_array) const // new_ownership (already allocated) { base::data().permutation_apply (new_numbering.data(), new_array.data()); } void reverse_permutation ( // old_ownership for *this=iold2dis_inew hack_array& inew2dis_iold) const // new_ownership { base::data().reverse_permutation (inew2dis_iold.data()); } #endif // TODO // i/o: odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); } idiststream& get_values (idiststream& ips) { return base::data().get_values(ips); } #ifdef TODO void dump (std::string name) const { return base::data().dump(name); } #endif // TODO template idiststream& get_values (idiststream& ips, GetFunction get_element) { return base::data().get_values(ips, get_element); } template odiststream& put_values (odiststream& ops, PutFunction put_element) const { return base::data().put_values(ops, put_element); } template odiststream& permuted_put_values ( odiststream& ops, const Permutation& perm, PutFunction put_element) const { return base::data().permuted_put_values (ops, perm.data(), put_element); } }; .Sp .fi .\" end_example