示例#1
0
void CudaModule::launchKernel(CUfunction kernel, const Vec2i& blockSize, 
                              const Vec2i& gridSize, bool async, 
                              CUstream stream)
{
  if (!kernel) {
    fail("CudaModule: No kernel specified!");
  }

#if (CUDA_VERSION >= 3000)
  if (NULL != cuFuncSetCacheConfig)
  {
    CUfunc_cache cache = (s_preferL1)? CU_FUNC_CACHE_PREFER_L1 : 
                                       CU_FUNC_CACHE_PREFER_SHARED;  
    checkError("cuFuncSetCacheConfig", cuFuncSetCacheConfig( kernel, cache) );
  }
#endif

  updateGlobals();
  updateTexRefs(kernel);
  checkError("cuFuncSetBlockShape", cuFuncSetBlockShape(kernel, blockSize.x, blockSize.y, 1));

  if (async && (NULL != cuLaunchGridAsync)) 
  {
    checkError("cuLaunchGridAsync", 
                cuLaunchGridAsync(kernel, gridSize.x, gridSize.y, stream));
  } 
  else 
  {
    checkError("cuLaunchGrid", 
                cuLaunchGrid(kernel, gridSize.x, gridSize.y));
  }
}
示例#2
0
F32 CudaModule::launchKernelTimed(CUfunction kernel, const Vec2i& blockSize, 
                                  const Vec2i& gridSize, bool async, 
                                  CUstream stream, bool yield)
{
  // Update globals before timing.
  updateGlobals();
  updateTexRefs(kernel);
  sync(false);


  // Events not supported => use CPU-based timer.
  if (!s_startEvent)
  {
    assert(0);//
#if 0
    Timer timer(true);
    launchKernel(kernel, blockSize, gridSize, async, stream);
    sync(false); // spin for more accurate timing
    return timer.getElapsed();
#endif
  }


  // Use events.
  checkError("cuEventRecord", cuEventRecord(s_startEvent, NULL));
  launchKernel(kernel, blockSize, gridSize, async, stream);
  checkError("cuEventRecord", cuEventRecord(s_endEvent, NULL));
  sync(yield);

  F32 time;
  checkError("cuEventElapsedTime", cuEventElapsedTime(&time, s_startEvent, s_endEvent));
  return time * 1.0e-3f;
}
void DataStore::moveItemDown( int row )
{
    if ( row >= 0 && row < m_datasetList.size() - 1 )
    {
        beginMoveRows( index( row, 0 ), row, row, index( row + 1, 0 ), row + 1 );
        m_datasetList.swap( row, row + 1 );
        endMoveRows();
        updateGlobals( row );
        emit ( dataChanged( index( 0, 0 ), index( 0, 0 ) ) );
    }
}
/*!
  Begins the testing process.  The list of grasps to test is provided in
  \a graspList_in , and \a render_in controls whether the movement of the hand
  will be shown during the testing process.  It helps to understand what is
  going on, but slows down the process.

  This saves the current hand configuration, so that after testing is complete
  it can be returned to it's original state.  However, we may want to create
  a separate copy of the main world in which to perform the testing, so we
  don't make any changes to the main world.

  An Inventor idleSensor is created to call the testing callback whenever the
  user is idle.  This means that the testing won't interfere with user
  interaction like changing the camera viewpoint.
*/
bool
grasp_tester::callTestIt(std::list<plannedGrasp *> &graspList_in, bool render_in)
{
  /* check if another testing process is running */
  if (idleSensor) { return false; }

  /* get global stuff from ivmgr */
  updateGlobals();

  /* check if at least one quality measure exists */
  if (whichQM < 0) {
#ifdef GRASPITDBG
    std::cout << "PL_OUT: No quality measure specified. Do that first!" << std::endl;
#endif
    return false;
  }

  /* check if any planned grasps in list */
  if (graspList_in.empty()) {
#ifdef GRASPITDBG
    std::cout << "PL_OUT: Tester received empty grasp list. Nothing happened." << std::endl;
#endif
    return false;
  }

  nrOfGrasps = graspList_in.size();
  actualGraspNr = 0;

  graspList = &graspList_in;
  render = render_in;

  /* Save old hand transformation */
  origTran = my_hand->getTran();
  dofs = new double[my_hand->getNumDOF()];
  for (int i = 0; i < my_hand->getNumDOF(); i++) {
    dofs[i] = my_hand->getDOF(i)->getVal();
  }

  /* set starting iterator for thread */
  it_gr = (*graspList).begin();

  PROF_RESET_ALL;
  PROF_START_TIMER(TOTAL_PLANNER);

  /* start thread */
  idleSensor = new SoIdleSensor(testItCB, NULL);
  idleSensor->schedule();

  return true;
}
void DataStore::deleteItem( int row )
{
    if ( row >= 0 && row < m_datasetList.size() )
    {
        beginRemoveRows( index( row, 0 ), row, row );
        Dataset* toDelete = VPtr<Dataset>::asPtr( m_datasetList.at( row ) );
        m_datasetList.removeAt( row );
        endRemoveRows();
        beginResetModel();
        reset();
        endResetModel();
        emit ( dataChanged( index( 0, 0 ), index( 0, 0 ) ) );
        delete toDelete;
        updateGlobals( row );
    }
}
示例#6
0
/*!
  Presents the next planned and tested grasp to the user.  Currently
  this is done in the main window, but it might be better to create
  a separate window for the presentation of the grasp.  The sorted list of
  grasps to present is passed to this class with takeList .  \a next has
  no effect right now.  The idea was to be able to show previous grasps as
  well.  \a render is passed to the putHand and determines whether the
  movement of the hand as it grasps the object is shown or not.
*/
void
grasp_presenter::showGrasp(int next, bool render){

    if (!graspList.empty()){
	updateGlobals();

	/* Here, a separate window should be opened with copies of
	   the hand, the robot, the object and all obstacles */


	/* Show all grasps beginning with the best */
	if (processing == -1){
	    it_gr = graspList.begin();
	    processing = 0;
	}

	if (next >=0) {
#ifdef GRASPITDBG
	  std::cout << "PL_OUT: Showing next grasp." << std::endl;
	}
	else {
	  std::cout<<"PL_OUT: Previous not implemented. Showing next instead." << std::endl;
#endif
	}

	if ((*it_gr)->get_quality() > 0.0){
	    putHand((*it_gr)->get_finalGraspPosition(), render);
#ifdef GRASPITDBG
	    std::cout << "PL_OUT: Grasp Nr " << processing << std::endl;
	    std::cout << "PL_OUT: Quality: " << (*it_gr)->get_quality() << std::endl;
#endif
	    myViewer->render();
	}
	it_gr++;
	processing++;
	if (it_gr == graspList.end()){
	    it_gr = graspList.begin();
	    processing = 0;
	}
    }
#ifdef GRASPITDBG
    else std::cout << "PL_OUT: No grasps planned yet. There's nothin to show." << std::endl;
#endif
}
/*!
  Sets up the grasp visualization window.  If one exists already it is
  deleted.  The window consists of a render area, and the scene graph uses
  the same camera as the main viewer.  The primitives sub-graph, pointed to by
  \a prim , is added using the same transform as \a myBody has in the main
  world.  The candidate grasps can then be added to this scene later.
*/
void
grasp_tester::setupGraspVisWindow(GraspableBody *myBody, SoGroup *prim)
{

  if (projectionViewer) {
    QWidget *topShell = projectionViewer->getShellWidget();
    delete projectionViewer;
    delete topShell;
  }

  /* get global stuff from ivmgr */
  updateGlobals();

  SoSeparator *VisTop = new SoSeparator();
  SoTransformSeparator *lightSep = new SoTransformSeparator();
  SoRotation *lightDir = new SoRotation();
  SoSeparator *objSep = new SoSeparator();
  glRoot = new SoSeparator();

  lightDir->rotation.connectFrom(&myViewer->getCamera()->orientation);
  lightSep->addChild(lightDir);
  lightSep->addChild(myViewer->getHeadlight());

  objSep->addChild(myBody->getIVTran());
  objSep->addChild(prim);

  VisTop->addChild(myViewer->getCamera());
  VisTop->addChild(lightSep);
  VisTop->addChild(objSep);
  VisTop->addChild(glRoot);

  projectionViewer = new SoQtRenderArea();
  projectionViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
  projectionViewer->setBackgroundColor(SbColor(1, 1, 1));
  projectionViewer->setTitle("GraspIt!");

  projectionViewer->setSceneGraph(VisTop);
  projectionViewer->show();
}
bool DataStore::setData( const QModelIndex &index, const QVariant &value, int role )
{
    //qDebug() << "row: " << index.row() << "column: " << index.column() << "role: " << role;
    if ( index.column() != (int)Fn::Property::NEW_DATASET && !index.isValid() )
    {
        return false;
    }

    if ( role == Qt::CheckStateRole )
    {
        Dataset* ds = VPtr<Dataset>::asPtr( m_datasetList.at( index.row() ) );
        ds->properties()->set( Fn::Property::ACTIVE, !ds->properties()->get( Fn::Property::ACTIVE ).toBool() );
        emit( dataChanged( index, index ) );
    }

    if ( role == Qt::DisplayRole )
    {
        // handle props with special treatment
        if ( index.column() == (int)Fn::Property::NEW_DATASET )
        {
            beginInsertRows( QModelIndex(), m_datasetList.size(), m_datasetList.size() );
            m_datasetList.push_back( value );
            endInsertRows();
            connect( VPtr<Dataset>::asPtr( value )->properties(), SIGNAL( signalPropChanged() ), this, SLOT( submit() ) );
            updateGlobals( m_datasetList.size() - 1 );
            emit( dataChanged( index, index ) );
            return true;
        }
        // everything else
        if ( index.row() >= 0 && index.row() < m_datasetList.size() )
        {
            VPtr<Dataset>::asPtr( m_datasetList.at( index.row() ) )->properties()->set( (Fn::Property)index.column(), value );
        }
        return true;
    }
    return false;
}
	void ATIExecutableKernel::updateMemory()
	{
		updateGlobals();
	}
示例#10
0
int CALLBACK driver_optionsProc(HWND   hdlg,
                           WORD   wMsg,
                           WPARAM wParam,
                           LPARAM lParam)
{
	switch (wMsg) {
	case WM_INITDIALOG:

		CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
		CheckDlgButton(hdlg, DRV_OPTIMIZER, globals.disable_optimizer);
		CheckDlgButton(hdlg, DRV_KSQO, globals.ksqo);
		CheckDlgButton(hdlg, DRV_UNIQUEINDEX, globals.unique_index);
		CheckDlgButton(hdlg, DRV_READONLY, globals.readonly);
		CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, globals.use_declarefetch);

		/*	Unknown (Default) Data Type sizes */
		switch(globals.unknown_sizes) {
		case UNKNOWNS_AS_DONTKNOW:
			CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1);
			break;
		case UNKNOWNS_AS_LONGEST:
			CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1);
			break;
		case UNKNOWNS_AS_MAX:
		default:
			CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1);
			break;
		}

		CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, globals.text_as_longvarchar);
		CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, globals.unknowns_as_longvarchar);
		CheckDlgButton(hdlg, DRV_BOOLS_CHAR, globals.bools_as_char);

		CheckDlgButton(hdlg, DRV_PARSE, globals.parse);

		CheckDlgButton(hdlg, DRV_CANCELASFREESTMT, globals.cancel_as_freestmt);

		SetDlgItemInt(hdlg, DRV_CACHE_SIZE, globals.fetch_max, FALSE);
		SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, globals.max_varchar_size, FALSE);
		SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, globals.max_longvarchar_size, TRUE);

		SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes);

		/*	Driver Connection Settings */
		SetDlgItemText(hdlg, DRV_CONNSETTINGS, globals.conn_settings);

		break;

	case WM_COMMAND:
		switch (GET_WM_COMMAND_ID(wParam, lParam)) {
		case IDOK:

			globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
			globals.disable_optimizer = IsDlgButtonChecked(hdlg, DRV_OPTIMIZER);
			globals.ksqo = IsDlgButtonChecked(hdlg, DRV_KSQO);
			globals.unique_index = IsDlgButtonChecked(hdlg, DRV_UNIQUEINDEX);
			globals.readonly = IsDlgButtonChecked(hdlg, DRV_READONLY);
			globals.use_declarefetch = IsDlgButtonChecked(hdlg, DRV_USEDECLAREFETCH);

			/*	Unknown (Default) Data Type sizes */
			if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_MAX))
				globals.unknown_sizes = UNKNOWNS_AS_MAX;
			else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_DONTKNOW))
				globals.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
			else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_LONGEST))
				globals.unknown_sizes = UNKNOWNS_AS_LONGEST;
			else
				globals.unknown_sizes = UNKNOWNS_AS_MAX;

			globals.text_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_TEXT_LONGVARCHAR);
			globals.unknowns_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_UNKNOWNS_LONGVARCHAR);
			globals.bools_as_char = IsDlgButtonChecked(hdlg, DRV_BOOLS_CHAR);

			globals.parse = IsDlgButtonChecked(hdlg, DRV_PARSE);

			globals.cancel_as_freestmt = IsDlgButtonChecked(hdlg, DRV_CANCELASFREESTMT);

			globals.fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
			globals.max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
			globals.max_longvarchar_size= GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE);	/*// allows for SQL_NO_TOTAL */

			GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, sizeof(globals.extra_systable_prefixes));

			/*	Driver Connection Settings */
			GetDlgItemText(hdlg, DRV_CONNSETTINGS, globals.conn_settings, sizeof(globals.conn_settings));

			updateGlobals();

			/*//	fall through */

		case IDCANCEL:
			EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
			return TRUE;

		case IDDEFAULTS:
			CheckDlgButton(hdlg, DRV_COMMLOG, DEFAULT_COMMLOG);
			CheckDlgButton(hdlg, DRV_OPTIMIZER, DEFAULT_OPTIMIZER);
			CheckDlgButton(hdlg, DRV_KSQO, DEFAULT_KSQO);
			CheckDlgButton(hdlg, DRV_UNIQUEINDEX, DEFAULT_UNIQUEINDEX);
			CheckDlgButton(hdlg, DRV_READONLY, DEFAULT_READONLY);
			CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, DEFAULT_USEDECLAREFETCH);
	
			CheckDlgButton(hdlg, DRV_PARSE, DEFAULT_PARSE);
			CheckDlgButton(hdlg, DRV_CANCELASFREESTMT, DEFAULT_CANCELASFREESTMT);

			/*	Unknown Sizes */
			CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 0);
			CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 0);
			CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 0);
			switch(DEFAULT_UNKNOWNSIZES) {
			case UNKNOWNS_AS_DONTKNOW:
				CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1);
				break;
			case UNKNOWNS_AS_LONGEST:
				CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1);
				break;
			case UNKNOWNS_AS_MAX:
				CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1);
				break;
			}

			CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, DEFAULT_TEXTASLONGVARCHAR);
			CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, DEFAULT_UNKNOWNSASLONGVARCHAR);
			CheckDlgButton(hdlg, DRV_BOOLS_CHAR, DEFAULT_BOOLSASCHAR);

			SetDlgItemInt(hdlg, DRV_CACHE_SIZE, FETCH_MAX, FALSE);
			SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, MAX_VARCHAR_SIZE, FALSE);
			SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, TEXT_FIELD_SIZE, TRUE);

			SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, DEFAULT_EXTRASYSTABLEPREFIXES);

			/*	Driver Connection Settings */
			SetDlgItemText(hdlg, DRV_CONNSETTINGS, "");

			break;
		}

	}

	return FALSE;
}