Ejemplo n.º 1
0
/**
 * Spawning constructor.  This will actually start a new thread that will
 * execute the specified function.
 */
ThreadSGI::ThreadSGI(const vpr::thread_func_t& func,
                     BaseThread::VPRThreadPriority priority,
                     BaseThread::VPRThreadScope scope,
                     BaseThread::VPRThreadState state, size_t stackSize)
   : mRunning(false)
   , mCaughtException(false)
   , mException("No exception caught")
{
   // Create the thread functor to start.
   setFunctor(func);
   start();
}
Ejemplo n.º 2
0
ImageSourcePtr< TImage > URIHandler::newImageSource() const
{
    EventSourcePtr eventSource = newEventSource();

    ImageSourcePtr< TImage > source;
    switch( getType( ))
    {
    case VolumeType::spikes:
    case VolumeType::synapses:
    case VolumeType::vsd:
        source = EventValueSummationImageSource< TImage >::New();
        break;
    default:
#ifdef FIVOX_USE_CUDA
        bool cudaCapable = false;
        if( getFunctorType() == FunctorType::lfp )
        {
            int deviceCount = 0;
            if( cudaGetDeviceCount( &deviceCount ) != cudaSuccess )
                deviceCount = 0;

            cudaCapable = deviceCount > 0;
            if( cudaCapable )
            {
                LBINFO << "CUDA-capable device is detected. "
                       << "Using GPU implementation." << std::endl;
                source = CudaImageSource< TImage >::New();
            }
        }
        if( !cudaCapable )
#endif
        {
            LBINFO << "No CUDA-capable device is detected. "
                   << "Using CPU implementation." << std::endl;
            auto functorSource = FunctorImageSource< TImage >::New();
            auto functor = newFunctor< TImage >();
            functorSource->setFunctor( functor );
            functor->setEventSource( eventSource );
            source = functorSource;
        }
    }

    LBINFO << "Ready to voxelize " << *this << ", dt = "
           << eventSource->getDt() << std::endl;

    source->setEventSource( eventSource );
    source->setup( *this );
    return source;
}
Ejemplo n.º 3
0
// Spawning constructor with arguments.  This will start a new thread that will
// execute the specified function.
ThreadPosix::ThreadPosix(const vpr::thread_func_t& func,
                         VPRThreadPriority priority,
                         VPRThreadScope scope, VPRThreadState state,
                         size_t stackSize)
   : mRunning(false)
   , mPriority(priority)
   , mScope(scope)
   , mState(state)
   , mStackSize(stackSize)
   , mException("No exception caught")
   , mCaughtException(false)
   , mThreadStartCompleted(false)
{
   setFunctor(func);
   start();
}