Exemplo n.º 1
0
ArrayDatum
get_children( const index node_id, const DictionaryDatum& params, const bool include_remotes )
{
  Subnet* subnet = dynamic_cast< Subnet* >( kernel().node_manager.get_node( node_id ) );
  if ( subnet == NULL )
  {
    throw SubnetExpected();
  }

  LocalChildList localnodes( *subnet );
  ArrayDatum result;

  std::vector< MPIManager::NodeAddressingData > globalnodes;
  if ( params->empty() )
  {
    kernel().mpi_manager.communicate( localnodes, globalnodes, include_remotes );
  }
  else
  {
    kernel().mpi_manager.communicate( localnodes, globalnodes, params, include_remotes );
  }
  result.reserve( globalnodes.size() );
  for ( std::vector< MPIManager::NodeAddressingData >::iterator n = globalnodes.begin();
        n != globalnodes.end();
        ++n )
  {
    result.push_back( new IntegerDatum( n->get_gid() ) );
  }

  return result;
}
Exemplo n.º 2
0
void
ConnectionManager::get_connections( ArrayDatum& connectome,
  TokenArray const* source,
  TokenArray const* target,
  size_t syn_id ) const
{
  size_t num_connections = 0;

  for ( thread t = 0; t < net_.get_num_threads(); ++t )
    num_connections += prototypes_[ t ][ syn_id ]->get_num_connections();

  connectome.reserve( num_connections );

  if ( source == 0 and target == 0 )
  {
#ifdef _OPENMP
#pragma omp parallel
    {
      thread t = net_.get_thread_id();
#else
    for ( thread t = 0; t < net_.get_num_threads(); ++t )
    {
#endif
      ArrayDatum conns_in_thread;
      size_t num_connections_in_thread = 0;
      // Count how many connections we will have.
      for ( tSConnector::const_nonempty_iterator it = connections_[ t ].nonempty_begin();
            it != connections_[ t ].nonempty_end();
            ++it )
      {
        num_connections_in_thread += validate_pointer( *it )->get_num_connections();
      }

#ifdef _OPENMP
#pragma omp critical
#endif
      conns_in_thread.reserve( num_connections_in_thread );
      for ( index source_id = 1; source_id < connections_[ t ].size(); ++source_id )
      {
        if ( connections_[ t ].get( source_id ) != 0 )
          validate_pointer( connections_[ t ].get( source_id ) )
            ->get_connections( source_id, t, syn_id, conns_in_thread );
      }
      if ( conns_in_thread.size() > 0 )
      {
#ifdef _OPENMP
#pragma omp critical
#endif
        connectome.append_move( conns_in_thread );
      }
    }

    return;
  }
Exemplo n.º 3
0
ArrayDatum
get_nodes( const index node_id,
  const DictionaryDatum& params,
  const bool include_remotes,
  const bool return_gids_only )
{
  Subnet* subnet = dynamic_cast< Subnet* >( kernel().node_manager.get_node( node_id ) );
  if ( subnet == NULL )
    throw SubnetExpected();

  LocalNodeList localnodes( *subnet );
  std::vector< MPIManager::NodeAddressingData > globalnodes;
  if ( params->empty() )
  {
    kernel().mpi_manager.communicate( localnodes, globalnodes, include_remotes );
  }
  else
  {
    kernel().mpi_manager.communicate( localnodes, globalnodes, params, include_remotes );
  }

  ArrayDatum result;
  result.reserve( globalnodes.size() );
  for ( std::vector< MPIManager::NodeAddressingData >::iterator n = globalnodes.begin();
        n != globalnodes.end();
        ++n )
  {
    if ( return_gids_only )
    {
      result.push_back( new IntegerDatum( n->get_gid() ) );
    }
    else
    {
      DictionaryDatum* node_info = new DictionaryDatum( new Dictionary );
      ( **node_info )[ names::global_id ] = n->get_gid();
      ( **node_info )[ names::vp ] = n->get_vp();
      ( **node_info )[ names::parent ] = n->get_parent_gid();
      result.push_back( node_info );
    }
  }

  return result;
}