void ConnectionManager::delete_connections_() { for ( tVSConnector::iterator it = connections_.begin(); it != connections_.end(); ++it ) for ( tSConnector::nonempty_iterator iit = it->nonempty_begin(); iit != it->nonempty_end(); ++iit ) #ifdef USE_PMA validate_pointer( *iit )->~ConnectorBase(); #else delete validate_pointer( *iit ); #endif #if defined _OPENMP && defined USE_PMA #ifdef IS_K #pragma omp parallel { poormansallocpool[ omp_get_thread_num() ].destruct(); poormansallocpool[ omp_get_thread_num() ].init(); } #else #pragma omp parallel { poormansallocpool.destruct(); poormansallocpool.init(); } #endif #endif }
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; }
void proc_sanity_check() { job_t *j; job_t *fg_job = 0; job_iterator_t jobs; while ((j = jobs.next())) { process_t *p; if (!job_get_flag(j, JOB_CONSTRUCTED)) continue; validate_pointer(j->first_process, _(L"Process list pointer"), 0); // More than one foreground job? if (job_get_flag(j, JOB_FOREGROUND) && !(job_is_stopped(j) || job_is_completed(j))) { if (fg_job != 0) { debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"), fg_job->command_wcstr(), j->command_wcstr()); sanity_lose(); } fg_job = j; } p = j->first_process; while (p) { // Internal block nodes do not have argv - see issue #1545. bool null_ok = (p->type == INTERNAL_BLOCK_NODE); validate_pointer(p->get_argv(), _(L"Process argument list"), null_ok); validate_pointer(p->argv0(), _(L"Process name"), null_ok); validate_pointer(p->next, _(L"Process list pointer"), true); if ((p->stopped & (~0x00000001)) != 0) { debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"), j->command_wcstr(), p->argv0(), p->stopped); sanity_lose(); } if ((p->completed & (~0x00000001)) != 0) { debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"), j->command_wcstr(), p->argv0(), p->completed); sanity_lose(); } p = p->next; } } }
DictionaryDatum ConnectionManager::get_synapse_status( index gid, synindex syn_id, port p, thread tid ) { assert_valid_syn_id( syn_id ); DictionaryDatum dict( new Dictionary ); validate_pointer( connections_[ tid ].get( gid ) )->get_synapse_status( syn_id, dict, p ); ( *dict )[ names::source ] = gid; ( *dict )[ names::synapse_model ] = LiteralDatum( get_synapse_prototype( syn_id ).get_name() ); return dict; }
void ConnectionManager::set_synapse_status( index gid, synindex syn_id, port p, thread tid, const DictionaryDatum& dict ) { assert_valid_syn_id( syn_id ); try { validate_pointer( connections_[ tid ].get( gid ) ) ->set_synapse_status( syn_id, *( prototypes_[ tid ][ syn_id ] ), dict, p ); } catch ( BadProperty& e ) { throw BadProperty( String::compose( "Setting status of '%1' connecting from GID %2 to port %3: %4", prototypes_[ tid ][ syn_id ]->get_name(), gid, p, e.message() ) ); } }
void proc_sanity_check() { job_t *j; job_t *fg_job=0; job_iterator_t jobs; while ((j = jobs.next())) { process_t *p; if( !job_get_flag( j, JOB_CONSTRUCTED ) ) continue; validate_pointer( j->first_process, _( L"Process list pointer" ), 0 ); /* More than one foreground job? */ if( job_get_flag( j, JOB_FOREGROUND ) && !(job_is_stopped(j) || job_is_completed(j) ) ) { if( fg_job != 0 ) { debug( 0, _( L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"), fg_job->command_wcstr(), j->command_wcstr() ); sanity_lose(); } fg_job = j; } p = j->first_process; while( p ) { validate_pointer( p->get_argv(), _( L"Process argument list" ), 0 ); validate_pointer( p->argv0(), _( L"Process name" ), 0 ); validate_pointer( p->next, _( L"Process list pointer" ), 1 ); validate_pointer( p->actual_cmd, _( L"Process command" ), 1 ); if ( (p->stopped & (~0x00000001)) != 0 ) { debug( 0, _( L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d" ), j->command_wcstr(), p->argv0(), p->stopped ); sanity_lose(); } if ( (p->completed & (~0x00000001)) != 0 ) { debug( 0, _( L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d" ), j->command_wcstr(), p->argv0(), p->completed ); sanity_lose(); } p=p->next; } } }