int main(int argc, char** argv)
{
	std::wcout << accelerator(accelerator::default_accelerator).description << std::endl;

	if(argc > 1) {
		Simulate(argv[1]);
	}

	return 0;
}
Beispiel #2
0
int main(int argc, char** argv)
{
	std::wcout << accelerator(accelerator::default_accelerator).description << std::endl;

	if(argc > 1) {
		Simulate(argv[1]);
	}
	else
	{
		Simulate("C:\\simulation_json\\Data0.json");
	}

	return 0;
}
 /**
 ********************************************************************************
 * @fn setDefaultAccelerator
 * @brief Set a default accelerator
 *******************************************************************************/
 int setDefaultAccelerator()
 {
     std::vector<accelerator> allAccl = accelerator::get_all();
     /**************************************************************************
     * if deviceID is not set, the default accelerator is AMD Readon           *
     **************************************************************************/
     if(!enableDeviceId)
     {
         for (unsigned i = 0; i < allAccl.size(); ++i)
         {
             if (allAccl[i].get_description().find(L"AMD Radeon") != std::wstring::npos ||
                     allAccl[i].get_description().find(L"ATI Radeon") != std::wstring::npos )
             {
                 deviceAccl = allAccl[i];
                 break;
             }
         }
     }
     else
     {
         deviceAccl = allAccl[deviceId];
     }
     accelerator::set_default(deviceAccl.device_path);
     std::wcout << L"Selected accelerator : " << deviceAccl.get_description()
                << std::endl;
     if (deviceAccl == accelerator(accelerator::direct3d_ref))
     {
         std::cout << "WARNING!! Running on very slow emulator!" << std::endl;
     }
     if(deviceAccl == accelerator(accelerator::cpu_accelerator))
     {
         std::cout << "There is no need to run on single CPU !"<<std::endl;
         return SDK_FAILURE;
     }
     return SDK_SUCCESS;
 }
Beispiel #4
0
void main(int argc, char *argv[])
{
  try
  {
    IAccelerator accelerator(QF_ID);

    QuickFlick::initialize();
    movieFrame = new MovieFrame;
    if (argc > 1)
      movieFrame->setMovie(argv[1]);
    else
      movieFrame->showWindow();
    IApplication::current().run();

    delete movieFrame;
    QuickFlick::shutdown();
  }
  catch (IException ie)
  {
  }
}
Beispiel #5
0
int SPMV<T>::runArray_View()
{
    array_view<T, 1>  *dCSRVals = NULL;
    array_view<T, 1>  *dELLPACKRVals = NULL;
    array_view<int,1> *dCSRCols = NULL;
    array_view<int,1> *dCSRRows = NULL;
    array_view<int,1> *dELLPACKRCols = NULL;
    array_view<int,1> *dELLPACKRRows = NULL;
    int status = SDK_SUCCESS;
    storeArrayOut.resize(denseEdge);

    if(Layout == SparseLayout::CSR)
    {
        dCSRVals = new array_view<T, 1> (nNonZeros, csrVals);
        dCSRCols = new array_view<int,1> (nNonZeros, csrCols);
        dCSRRows = new array_view<int,1> (denseEdge + 1, csrRows);
    }
    else
    {
        dELLPACKRVals = new array_view<T, 1> (ellpackrRowMax * denseEdge, ellpackrVals);
        dELLPACKRCols = new array_view<int,1> (ellpackrRowMax * denseEdge,
                                               ellpackrCols);
        dELLPACKRRows = new array_view<int,1> (denseEdge, ellpackrRows);
    }
    array_view<T, 1> dInVector (denseEdge, inVector);
    array_view<T, 1> dOutVector(denseEdge,storeArrayOut);
    // accelerator view for synchronize
    accelerator_view &accView = accelerator().default_view;

    //warm up
    if(Layout == SparseLayout::CSR)
    {
        SPMVCSR(*dCSRVals, *dCSRCols, *dCSRRows, dInVector, dOutVector, denseEdge,
                nNonZeros);
    }
    else
    {
        SPMVELLPACKR(*dELLPACKRVals, *dELLPACKRCols, *dELLPACKRRows, dInVector,
                     dOutVector, denseEdge);
    }
    dOutVector.synchronize();

    //calculate total time
    int timer = sampleTimer->createTimer();
    status = sampleTimer->resetTimer(timer);
    status = sampleTimer->startTimer(timer);
    for(int run = 0; run < iter; ++run)
    {
        // Execute and time the kernel.
        if(Layout == SparseLayout::CSR)
        {
            SPMVCSR(*dCSRVals, *dCSRCols, *dCSRRows, dInVector, dOutVector, denseEdge,
                    nNonZeros);
        }
        else
        {
            SPMVELLPACKR(*dELLPACKRVals, *dELLPACKRCols, *dELLPACKRRows, dInVector,
                         dOutVector, denseEdge);
        }
        accView.flush();
    }
    dOutVector.synchronize();
    status = sampleTimer->stopTimer(timer);
    if(status != SDK_SUCCESS)
    {
        return SDK_FAILURE;
    }
    totalTime = (double)(sampleTimer->readTimer(timer));
    if(dCSRVals != NULL)
    {
        delete dCSRVals;
    }
    if(dCSRCols != NULL)
    {
        delete dCSRCols;
    }
    if(dCSRRows != NULL)
    {
        delete dCSRRows;
    }
    if(dELLPACKRVals != NULL)
    {
        delete dELLPACKRVals;
    }
    if(dELLPACKRCols != NULL)
    {
        delete dELLPACKRCols;
    }
    if(dELLPACKRRows != NULL)
    {
        delete dELLPACKRRows;
    }
    return SDK_SUCCESS;

}
Beispiel #6
0
int SPMV<T>::runArray()
{
    array<T, 1>  *dCSRVals = NULL;
    array<T, 1>  *dELLPACKRVals = NULL;
    array<int,1> *dCSRCols = NULL;
    array<int,1> *dCSRRows = NULL;
    array<int,1> *dELLPACKRCols = NULL;
    array<int,1> *dELLPACKRRows = NULL;
    int status = SDK_SUCCESS;
    storeArrayOut.resize(denseEdge);
    //calculate data copy time from cpu tp gpu
    int ctgTimer = sampleTimer->createTimer();
    status = sampleTimer->resetTimer(ctgTimer);
    status = sampleTimer->startTimer(ctgTimer);
    if(Layout == SparseLayout::CSR)
    {
        dCSRVals = new array<T, 1> (nNonZeros,csrVals.begin());
        dCSRCols = new array<int,1> (nNonZeros,csrCols.begin());
        dCSRRows = new array<int,1> (denseEdge + 1, csrRows.begin());
    }
    else
    {
        dELLPACKRVals = new array<T, 1> (ellpackrRowMax * denseEdge,
                                         ellpackrVals.begin());
        dELLPACKRCols = new array<int,1> (ellpackrRowMax * denseEdge,
                                          ellpackrCols.begin());
        dELLPACKRRows = new array<int,1> (denseEdge, ellpackrRows.begin());
    }
    array<T, 1> dInVector (denseEdge, inVector.begin());
    array<T, 1> dOutVector(denseEdge);
    status = sampleTimer->stopTimer(ctgTimer);
    if(status != SDK_SUCCESS)
    {
        return SDK_FAILURE;
    }
    cpToDeviceTime = (double)(sampleTimer->readTimer(ctgTimer));
    //warm up
    if(Layout == SparseLayout::CSR)
    {
        SPMVCSR(*dCSRVals, *dCSRCols, *dCSRRows, dInVector, dOutVector, denseEdge,
                nNonZeros);
    }
    else
    {
        SPMVELLPACKR(*dELLPACKRVals, *dELLPACKRCols, *dELLPACKRRows, dInVector,
                     dOutVector, denseEdge);
    }
    accelerator_view &accView = accelerator().default_view;
    accView.flush();
    accView.wait();

    //calculate total kernel execute time
    int timer = sampleTimer->createTimer();
    status = sampleTimer->resetTimer(timer);
    status = sampleTimer->startTimer(timer);
    for(int run = 0; run < iter; ++run)
    {
        // Execute and time the kernel.
        if(Layout == SparseLayout::CSR)
        {
            SPMVCSR(*dCSRVals, *dCSRCols, *dCSRRows, dInVector, dOutVector, denseEdge,
                    nNonZeros);
        }
        else
        {
            SPMVELLPACKR(*dELLPACKRVals, *dELLPACKRCols, *dELLPACKRRows, dInVector,
                         dOutVector, denseEdge);
        }

        accView.flush();
    }
    accView.wait();
    status = sampleTimer->stopTimer(timer);
    if(status != SDK_SUCCESS)
    {
        return SDK_FAILURE;
    }
    totalKernelTime = (double)(sampleTimer->readTimer(timer));
    averageKernelTime = totalKernelTime / iter;

    //calculate data copy time from gpu to cpu
    int gtcTimer = sampleTimer->createTimer();
    status = sampleTimer->resetTimer(gtcTimer);
    status = sampleTimer->startTimer(gtcTimer);
    copy(dOutVector, storeArrayOut.begin());
    status = sampleTimer->stopTimer(gtcTimer);
    if(status != SDK_SUCCESS)
    {
        return SDK_FAILURE;
    }
    cpToHostTime = (double)(sampleTimer->readTimer(gtcTimer));

    totalTime = cpToDeviceTime + totalKernelTime + cpToHostTime;
    if(dCSRVals != NULL)
    {
        delete dCSRVals;
    }
    if(dCSRCols != NULL)
    {
        delete dCSRCols;
    }
    if(dCSRRows != NULL)
    {
        delete dCSRRows;
    }
    if(dELLPACKRVals != NULL)
    {
        delete dELLPACKRVals;
    }
    if(dELLPACKRCols != NULL)
    {
        delete dELLPACKRCols;
    }
    if(dELLPACKRRows != NULL)
    {
        delete dELLPACKRRows;
    }
    return SDK_SUCCESS;
}
    bool FocusManager::OnKeyEvent(const KeyEvent& event)
    {
        // If the focused view wants to process the key event as is, let it be.
        // On Linux we always dispatch key events to the focused view first, so
        // we should not do this check here. See also WidgetGtk::OnKeyEvent().
        if(focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event))
        {
            return true;
        }

        // Intercept Tab related messages for focus traversal.
        // Note that we don't do focus traversal if the root window is not part of the
        // active window hierarchy as this would mean we have no focused view and
        // would focus the first focusable view.
        HWND top_window = widget_->GetNativeView();
        HWND active_window = ::GetActiveWindow();
        if((active_window==top_window || ::IsChild(active_window, top_window)) &&
            IsTabTraversalKeyEvent(event))
        {
            AdvanceFocus(event.IsShiftDown());
            return false;
        }

        // Intercept arrow key messages to switch between grouped views.
        KeyboardCode key_code = event.GetKeyCode();
        if(focused_view_ && focused_view_->GetGroup()!=-1 &&
            (key_code==VKEY_UP || key_code==VKEY_DOWN ||
            key_code==VKEY_LEFT || key_code==VKEY_RIGHT))
        {
            bool next = (key_code==VKEY_RIGHT || key_code==VKEY_DOWN);
            std::vector<View*> views;
            focused_view_->GetParent()->GetViewsWithGroup(
                focused_view_->GetGroup(), &views);
            std::vector<View*>::const_iterator iter = std::find(views.begin(),
                views.end(), focused_view_);
            DCHECK(iter != views.end());
            int index = static_cast<int>(iter - views.begin());
            index += next ? 1 : -1;
            if(index < 0)
            {
                index = static_cast<int>(views.size()) - 1;
            }
            else if(index >= static_cast<int>(views.size()))
            {
                index = 0;
            }
            SetFocusedViewWithReason(views[index], kReasonFocusTraversal);
            return false;
        }

        // Process keyboard accelerators.
        // If the key combination matches an accelerator, the accelerator is
        // triggered, otherwise the key event is processed as usual.
        Accelerator accelerator(event.GetKeyCode(),
            event.IsShiftDown(),
            event.IsControlDown(),
            event.IsAltDown());
        if(ProcessAccelerator(accelerator))
        {
            // If a shortcut was activated for this keydown message, do not propagate
            // the event further.
            return false;
        }
        return true;
    }