예제 #1
0
	void CloudStitcher::setupWorkerThreads( unsigned int thread_count , unsigned int num_files )
	{
		//offset is the number of pcd files that should be allocated to each thread
		unsigned int offset = (int)std::ceil( num_files / thread_count ) + 1;

		//current offset will be a changing variable representing where in the filename array we are looking at
		std::vector< std::string >::iterator current_offset = this->pcd_filenames->begin();

		//if we are using one thread, then just copy all of the filenames into the single thread
		if( thread_count == 1 )
		{
			std::vector< std::string > param_vec( current_offset , this->pcd_filenames->end() );
			this->worker_threads->push_back( new CloudStitcher::CloudStitchingThread( param_vec , this->output_buffer , &this->files_finished , this->filter_leaf_size ));
		}

		//otherwise we are going to divide up the filename array as evenly as possible among all the threads
		else
		{
			for( unsigned int i = 0 ; i < thread_count - 1 ; ++i )
			{
				std::vector< std::string >::iterator last = ( current_offset + offset );
				std::vector< std::string > param_vec( current_offset , last );
				this->worker_threads->push_back( new CloudStitcher::CloudStitchingThread( param_vec , this->output_buffer , &this->files_finished , this->filter_leaf_size ));
				current_offset = last - 1;
			}

			//to prevent a seg-fault we just copy whatever is left of the filename array into the last thread
			std::vector< std::string > param_vec( current_offset , this->pcd_filenames->end() );
			this->worker_threads->push_back( new CloudStitcher::CloudStitchingThread( param_vec , this->output_buffer , &this->files_finished , this->filter_leaf_size ));

		}
	}
예제 #2
0
inline void
nest::ConnBuilder::check_synapse_params_( std::string syn_name,
  const DictionaryDatum& syn_spec )
{
  // throw error if weight is specified with static_synapse_hom_w
  if ( syn_name == "static_synapse_hom_w" )
  {
    if ( syn_spec->known( names::weight ) )
      throw BadProperty(
        "Weight cannot be specified since it needs to be equal "
        "for all connections when static_synapse_hom_w is used." );
    return;
  }


  // throw error if n or a are set in quantal_stp_synapse, Connect cannot handle
  // them since they are integer
  if ( syn_name == "quantal_stp_synapse" )
  {
    if ( syn_spec->known( names::n ) )
      throw NotImplemented(
        "Connect doesn't support the setting of parameter "
        "n in quantal_stp_synapse. Use SetDefaults() or CopyModel()." );
    if ( syn_spec->known( names::a ) )
      throw NotImplemented(
        "Connect doesn't support the setting of parameter "
        "a in quantal_stp_synapse. Use SetDefaults() or CopyModel()." );
    return;
  }

  // print warning if delay is specified outside cont_delay_synapse
  if ( syn_name == "cont_delay_synapse" )
  {
    if ( syn_spec->known( names::delay ) )
      LOG( M_WARNING,
        "Connect",
        "The delay will be rounded to the next multiple of the time step. "
        "To use a more precise time delay it needs to be defined within "
        "the synapse, e.g. with CopyModel()." );
    return;
  }

  // throw error if no volume transmitter is defined or parameters are specified
  // that need to be introduced via CopyModel or SetDefaults
  if ( syn_name == "stdp_dopamine_synapse" )
  {
    if ( syn_spec->known( "vt" ) )
      throw NotImplemented(
        "Connect doesn't support the direct specification of the "
        "volume transmitter of stdp_dopamine_synapse in syn_spec."
        "Use SetDefaults() or CopyModel()." );
    // setting of parameter c and n not thread save
    if ( kernel().vp_manager.get_num_threads() > 1 )
    {
      if ( syn_spec->known( names::c ) )
        throw NotImplemented(
          "For multi-threading Connect doesn't support the setting "
          "of parameter c in stdp_dopamine_synapse. "
          "Use SetDefaults() or CopyModel()." );
      if ( syn_spec->known( names::n ) )
        throw NotImplemented(
          "For multi-threading Connect doesn't support the setting "
          "of parameter n in stdp_dopamine_synapse. "
          "Use SetDefaults() or CopyModel()." );
    }
    std::string param_arr[] = {
      "A_minus", "A_plus", "Wmax", "Wmin", "b", "tau_c", "tau_n", "tau_plus"
    };
    std::vector< std::string > param_vec( param_arr, param_arr + 8 );
    for ( std::vector< std::string >::iterator it = param_vec.begin();
          it != param_vec.end();
          it++ )
    {
      if ( syn_spec->known( *it ) )
        throw NotImplemented(
          "Connect doesn't support the setting of parameter " + *it
          + " in stdp_dopamine_synapse. Use SetDefaults() or CopyModel()." );
    }
    return;
  }
}