Beispiel #1
0
        void m_internalThread_DoWork(object sender, ActionStateArgs <T> e)
        {
            CudaDnn <T> cuda    = m_cuda;
            Log         log     = m_log;
            long        hStream = 0; // cuda.CreateStream(false);

            try
            {
                Batch <T> batch = new Batch <T>(cuda, log);

                while (!m_internalThread.CancellationPending)
                {
                    if (m_rgPrefetchFree.Pop(ref batch))
                    {
                        load_batch(batch);

                        batch.Data.AsyncGpuPush(hStream);
                        if (hStream != 0)
                        {
                            m_cuda.SynchronizeStream(hStream);
                        }

                        if (m_bOutputLabels)
                        {
                            batch.Label.AsyncGpuPush(hStream);
                            if (hStream != 0)
                            {
                                m_cuda.SynchronizeStream(hStream);
                            }
                        }

                        m_transformer.DistortImage(batch.Data);

                        m_rgPrefetchFull.Push(batch);
                    }
                }
            }
            catch (Exception excpt)
            {
                m_err = excpt;
                m_rgPrefetchFull.Abort();
                m_rgPrefetchFree.Abort();
                throw excpt;
            }
            finally
            {
                if (hStream != 0)
                {
                    cuda.FreeStream(hStream);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Release all GPU and Host resources used.
        /// </summary>
        public void Dispose()
        {
            if (m_hData != 0)
            {
                m_cuda.FreeMemory(m_hData);
                m_hData = 0;
            }

            if (m_hDiff != 0)
            {
                m_cuda.FreeMemory(m_hDiff);
                m_hDiff = 0;
            }

            if (m_hStream != 0)
            {
                m_cuda.FreeStream(m_hStream);
                m_hStream = 0;
            }
        }