STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types

Creates a new gang by partitioning the existing one from which the gang construction is invoked. More...

Public Member Functions

 gang (void)
 Creates a new gang of one location. More...
 
template<typename MappingFunction , typename ResolutionFunction >
 gang (const size_type size, MappingFunction &&mf, ResolutionFunction &&rf)
 Creates a new gang. More...
 
template<typename MappingFunction , typename ResolutionFunction >
 gang (const std::size_t id, const size_type size, MappingFunction &&mf, ResolutionFunction &&rf)
 Creates a new gang. More...
 
template<typename T >
 gang (T const &t)
 Switches to the gang of t.
 
void leave (void)
 Leaves the gang. More...
 
 gang (gang const &)=delete
 
gangoperator= (gang const &)=delete
 
void * operator new (std::size_t)=delete
 
void operator delete (void *)=delete
 
void * operator new[] (std::size_t)=delete
 
void operator delete[] (void *)=delete
 
void * operator new (std::size_t size, void *ptr) noexcept
 
void operator delete (void *ptr, void *ptr2) noexcept
 

Public Types

using size_type = runtime::gang_description::size_type
 

Detailed Description

Creates a new gang by partitioning the existing one from which the gang construction is invoked.

A new gang object has to be created in all locations that want to participate in it. It is the user's responsibility to ensure that.

The new gang is described by its size and two functions. The first function takes as input the id of a location in the creator gang and returns the id of a location in the created gang. The second function takes as input the id of a function in the created gang and returns the id of a location in the creator gang.

For example, creating a gang that includes all the even numbered locations of a gang can be done as follows:

struct even_fun
{
unsigned int operator()(unsigned int n) const
{ return (n/2); }
};
struct reverse_even_fun
{
unsigned int operator()(unsigned int n) const
{ return (2*n); }
};
int stapl_main(int, char**)
{
if (stapl::get_location_id()%2==0) {
even_fun(),
reverse_even_fun());
// gang created
// user code
} // gang is destroyed
return 0;
}

Constructor & Destructor Documentation

◆ gang() [1/3]

stapl::gang::gang ( void  )

Creates a new gang of one location.

The creation of the metadata is deferred until any kind of object registration (rmi_handle, p_object) or communication is required.

◆ gang() [2/3]

template<typename MappingFunction , typename ResolutionFunction >
stapl::gang::gang ( const size_type  size,
MappingFunction &&  mf,
ResolutionFunction &&  rf 
)

Creates a new gang.

The creation of the metadata requires communication to set up the gang id, therefore the construction will only finish until the id is received.

Parameters
sizeSize of the new gang.
mfMapping function to translate a location id from the creator gang to a location id in the created gang.
rfMapping function to translate a location id from the created gang to a location id in the creator gang.

◆ gang() [3/3]

template<typename MappingFunction , typename ResolutionFunction >
stapl::gang::gang ( const std::size_t  id,
const size_type  size,
MappingFunction &&  mf,
ResolutionFunction &&  rf 
)

Creates a new gang.

Since the id is given at construction, there is no communication required to set-up the gang id. However, the user is responsible for supplying an unused gang id.

Parameters
idId of the new gang.
sizeSize of the new gang.
mfMapping function to translate a location id from the creator gang to a location id in the created gang.
rfMapping function to translate a location id from the created gang to a location id in the creator gang.

Member Function Documentation

◆ leave()

void stapl::gang::leave ( void  )

Leaves the gang.

Warning
After this call, the section returns to the creator gang, therefore one should note that all communication happens in the creator gang with everything that this entails (e.g SPMD operations have to be called by all locations in the creator gang).

The documentation for this class was generated from the following files: