Esempio n. 1
0
void Triggerconf::createConfigElement (string module, string submodule, string configname)
{
	if (rootnode == NULL) return;
	
	if (existsConfigElement (module, submodule, configname)) {
		resetError ();	
		return;
	}

	DOMNode* currentSubmodule = selectSubmodule (module, submodule);
	if (currentSubmodule == NULL) return;

	XMLCh* xitemname	= XMLString::transcode (ELEMENT_CONFIGITEM_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xitemname);
	XMLString::release	(&xitemname);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xconfigname	= XMLString::transcode (configname.c_str ());
	node->setAttribute	(xattrname, xconfigname);
	XMLString::release	(&xattrname);
	XMLString::release	(&xconfigname);

	currentSubmodule->appendChild (node);

	resetError ();
}
Esempio n. 2
0
void Triggerconf::createSubmodule (string module, string submodule)
{
	if (rootnode == NULL) return;
	
	if (existsSubmodule (module, submodule)) {
		resetError ();	
		return;
	}

	DOMNode* currentModule	= selectModule (module);
	if (currentModule == NULL) return;
	
	XMLCh* xsubmodule	= XMLString::transcode (ELEMENT_SUBMODULE_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xsubmodule);
	XMLString::release	(&xsubmodule);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xsubmodulename	= XMLString::transcode (submodule.c_str ());
	node->setAttribute	(xattrname, xsubmodulename);
	XMLString::release	(&xattrname);
	XMLString::release	(&xsubmodulename);

	currentModule->appendChild (node);

	resetError ();
}
Esempio n. 3
0
DOMNode* Triggerconf::selectSubmodule (string modulename, string submodulename)
{
	DOMNode* currentModule = selectModule (modulename);

	if (currentModule == NULL) {
		setError ("invalid module: " + modulename);
		return NULL;
	}

	DOMNodeList* childs = currentModule->getChildNodes ();
	
	if (childs == NULL) {

		if (autocreate == false) {
			setError ("submodule " + modulename + " not found");
			return NULL; 
		} else {
			resetError ();
			createSubmodule (modulename, submodulename);
			return selectSubmodule (modulename, submodulename);
		}

	} // if (childs == NULL) 

	for (unsigned int i=0; i<childs->getLength (); i++) {
		
		DOMNode* node = childs->item (i);
		if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) continue;
		
		char* xmlstring = XMLString::transcode (node->getNodeName ());

		if (((string) ELEMENT_SUBMODULE_NAME).compare (xmlstring) != 0) {
			XMLString::release (&xmlstring);
			continue;
		}

		XMLString::release (&xmlstring);

		if ((getAttributeValue (node, ATTRIBUTE_NAME)).compare (submodulename) == 0) {		
			resetError ();		
			return node;
		}

	} // for (unsigned int i=0; i<childs->getLength (); i++)

	if (autocreate == false) {
		setError ("submodule " + submodulename + " not found");
		return NULL;
	} else {
		resetError ();
		createSubmodule (modulename, submodulename);
		return selectSubmodule (modulename, submodulename);
	}
}
SEXP getDeviceIDs(SEXP sPlatformID){
    resetError("ROpenCL::getDeviceIDs");
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);

    cl_uint num_GPUs = 0;
    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, 0, 0, &num_GPUs) );
    std::vector<cl_device_id> gpus(num_GPUs);
    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_GPU, num_GPUs, gpus.empty() ? NULL : &gpus.front(), &num_GPUs) );

    cl_uint num_nonGPUs = 0;
    logError( clGetDeviceIDs(*platformID, ~CL_DEVICE_TYPE_GPU, 0, 0, &num_nonGPUs) );
    std::vector<cl_device_id> devices(num_nonGPUs);
    logError( clGetDeviceIDs(*platformID, ~CL_DEVICE_TYPE_GPU, num_nonGPUs, devices.empty() ? NULL : &devices.front(), &num_nonGPUs) );

    //for each device in devices add its pointer to the return list
    Rcpp::List result(gpus.size() + devices.size());
    //To be more compatible with the previous version of this function, put GPUs first in the result list.
    for (int i=0; i<gpus.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = gpus[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i] = tempXPtr;
    }
    for (int i=0; i<devices.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = devices[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i+gpus.size()] = tempXPtr;
    }
    PRINTONERROR();
    return result;
}
SEXP getDeviceType(SEXP sDeviceID){
    resetError("ROpenCL::getDeviceType");
    Rcpp::XPtr<cl_device_id> deviceID(sDeviceID);
    std::string str = "UNKNOWN";
    
#ifdef CL_DEVICE_TYPE
    cl_device_type dt = 0;
    logError( clGetDeviceInfo(*deviceID,CL_DEVICE_TYPE, sizeof(cl_device_type), &dt, NULL) );
# ifdef CL_DEVICE_TYPE_DEFAULT
    if (dt & CL_DEVICE_TYPE_DEFAULT) str = "CL_DEVICE_TYPE_DEFAULT";
# endif
# ifdef CL_DEVICE_TYPE_CPU
    if (dt & CL_DEVICE_TYPE_CPU) str = "CL_DEVICE_TYPE_CPU";
# endif
# ifdef CL_DEVICE_TYPE_GPU
    if (dt & CL_DEVICE_TYPE_GPU) str = "CL_DEVICE_TYPE_GPU";
# endif
# ifdef CL_DEVICE_TYPE_ACCELERATOR
    if (dt & CL_DEVICE_TYPE_ACCELERATOR) str = "CL_DEVICE_TYPE_ACCELERATOR";
# endif
# ifdef CL_DEVICE_TYPE_CUSTOM
    if (dt & CL_DEVICE_TYPE_CUSTOM) str = "CL_DEVICE_TYPE_CUSTOM";
# endif
#endif

    PRINTONERROR();
    return Rcpp::wrap(str);
}
Esempio n. 6
0
Execution::Execution( QWidget *parent, FANN::neural_net *net, OfficeClient *client_, Qt::WindowFlags flags) :
    QWidget(parent, flags), Ui::Execution(), net(net), client(client_), maxEpochs(0), desiredMSE(0),
    trainingInputsSelection(client_),
    trainingReferenceSelection(client_),
    trainingErrorSelection(client_),
    testInputsSelection(client_),
    testReferenceSelection(client_),
    testErrorSelection(client_),
    testOutputsSelection(client_)
{
    assert(net && "Illegal program state, net uninitialized");
    setupUi( this );

    connect(trainingInputs, SIGNAL(clicked(bool)), this, SLOT(trainingInputsClicked()));
    connect(trainingReference, SIGNAL(clicked(bool)), this, SLOT(trainingReferenceClicked()));
    connect(trainingError, SIGNAL(clicked(bool)), this, SLOT(trainingErrorClicked()));

    connect(testInputs, SIGNAL(clicked(bool)), this, SLOT(testInputsClicked()));
    connect(testReference, SIGNAL(clicked(bool)), this, SLOT(testReferenceClicked()));
    connect(testError, SIGNAL(clicked(bool)), this, SLOT(testErrorClicked()));
    connect(testOutputs, SIGNAL(clicked(bool)), this, SLOT(testOutputsClicked()));

    connect(trainButton, SIGNAL(clicked(bool)), this, SLOT(runTraining()));
    connect(testButton, SIGNAL(clicked(bool)), this, SLOT(runTest()));
    connect(resetErrorButton, SIGNAL(clicked()), this, SLOT(resetError()));
}
SEXP getKernelWorkGroupInfo(SEXP sKernel, SEXP sDeviceID){
    resetError("ROpenCL::getKernelWorkGroupInfo");
    Rcpp::XPtr<cl_kernel> kernel(sKernel);
    Rcpp::XPtr<cl_device_id> deviceID(sDeviceID);
    size_t sval;
    size_t sizes[3];
    cl_ulong ulval;
    Rcpp::List result;
    
#ifdef CL_KERNEL_WORK_GROUP_SIZE /* size_t */
    sval = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_WORK_GROUP_SIZE, sizeof(sval), &sval, NULL) )) {
        result["CL_KERNEL_WORK_GROUP_SIZE"] = Rcpp::wrap(sval);
    }
#endif
#ifdef CL_KERNEL_COMPILE_WORK_GROUP_SIZE /* 3x size_t */
    sizes[0] = sizes[1] = sizes[2] = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, 3*sizeof(size_t), &sizes, NULL) )) {
        Rcpp::List wgs;
        wgs.push_back(Rcpp::wrap(sizes[0]));
        wgs.push_back(Rcpp::wrap(sizes[1]));
        wgs.push_back(Rcpp::wrap(sizes[2]));
        result["CL_KERNEL_COMPILE_WORK_GROUP_SIZE"] = Rcpp::wrap(wgs);
    }
#endif
#ifdef CL_KERNEL_LOCAL_MEM_SIZE /* ulong */
    ulval = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(ulval), &ulval, NULL) )) {
        result["CL_KERNEL_LOCAL_MEM_SIZE"] = Rcpp::wrap(ulval);
    }
#endif
#ifdef CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE /* size_t */
    sval = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, sizeof(sval), &sval, NULL) )) {
        result["CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE"] = Rcpp::wrap(sval);
    }
#endif
#ifdef CL_KERNEL_PRIVATE_MEM_SIZE /* ulong */
    ulval = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_PRIVATE_MEM_SIZE, sizeof(ulval), &ulval, NULL) )) {
        result["CL_KERNEL_PRIVATE_MEM_SIZE"] = Rcpp::wrap(ulval);
    }
#endif
//#ifdef CL_KERNEL_GLOBAL_WORK_SIZE /* 3x size_t */ TODO FIX THIS
/*
    sizes[0] = sizes[1] = sizes[2] = 0;
    if (!logError( clGetKernelWorkGroupInfo(*kernel, *deviceID, CL_KERNEL_GLOBAL_WORK_SIZE, 3*sizeof(size_t), &sizes, NULL) )) {
        Rcpp::List gws;
        gws.push_back(Rcpp::wrap(sizes[0]));
        gws.push_back(Rcpp::wrap(sizes[1]));
        gws.push_back(Rcpp::wrap(sizes[2]));
        result["CL_KERNEL_GLOBAL_WORK_SIZE"] = Rcpp::wrap(gws);
    }
*/
//#endif
    
    PRINTONERROR();
    return result;
}
Esempio n. 8
0
DOMNode* Triggerconf::selectConfigElement (string modulename, string submodulename, string configname)
{
	DOMNode* currentSubmodule = selectSubmodule (modulename, submodulename);
	if (currentSubmodule == NULL) {
		setError ("invalid submodule " + submodulename + " in module " + modulename);
		return NULL;
	}

	DOMNodeList* childs = currentSubmodule->getChildNodes ();
	if (childs == NULL) {
		setError ("submodule " + submodulename + " in module " + modulename + " not found");
		return NULL;
	}

	for (unsigned int i=0; i<childs->getLength (); i++) {
		
		DOMNode* child = childs->item (i);
		if (child == NULL || child->getNodeType () != DOMNode::ELEMENT_NODE) continue;

		char* xmlstring = XMLString::transcode (child->getNodeName ());

		if (((string) ELEMENT_CONFIGITEM_NAME).compare (xmlstring) != 0) {
			XMLString::release (&xmlstring);		
			continue;
		}

		XMLString::release (&xmlstring);		

		if ((getAttributeValue (child, ATTRIBUTE_NAME)).compare (configname) == 0) {		
			resetError ();		
			return child;
		}

	} // for (unsigned int i=0; i<childs->getLength (); i++) 

	if (autocreate == false) {
		setError ("configelement " + configname + " not found");
		return NULL; 
	} else {
		resetError ();
		createConfigElement (modulename, submodulename, configname);
		return selectConfigElement (modulename, submodulename, configname);
	}
}
SEXP getPlatformName(SEXP sPlatformID){
    resetError("ROpenCL::getPlatformName");
    char cBuffer[1024];
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL) );
    std::string retVal = cBuffer;
    PRINTONERROR();
    return Rcpp::wrap(retVal);
}
Esempio n. 10
0
void VBoxGlobalSettings::setHostCombo (const QString &hostCombo)
{
    if (!UIHostCombo::isValidKeyCombo (hostCombo))
    {
        last_err = tr ("'%1' is an invalid host-combination code-sequence.").arg (hostCombo);
        return;
    }
    mData()->hostCombo = hostCombo;
    resetError();
}
Esempio n. 11
0
EXP_OPTION void addError(int code, char *fileName, int line, char *assertion)
{
  //no errors found yet. Set a trace-back mark to the end of array.
  //printf("Error : %d at %s line %d, assertion %s\n", code, fileName, line, assertion);

  ThreadErrors	*threadErrors;
  THREAD_ID Tid = getTid();		//Find our identity

  threadErrors = findThreadErrorsByTid(Tid);
  //	printf("addError init: tid=%ld, threadErrors=%p\n", Tid, threadErrors);
  if (threadErrors == NULL) {	//This Tid has no entry in ThreadErrors table
    threadErrors = addThreadErrorsByTid(Tid);  // MEMLEAK:  ???
    if (threadErrors == NULL)
      return;				// What else can we do?
  }
	
  // printf("addError step 1 : tid=%ld, threadErrors=%p\n", Tid, threadErrors);
  if(threadErrors->currentErrorIdx < 0)
    resetError(&(threadErrors->ddocLastErrors[ERROR_BUF_LENGTH - 1]));

  threadErrors->currentErrorIdx++;

  //index at the end -> roll it over to the beginning
  if(threadErrors->currentErrorIdx == ERROR_BUF_LENGTH)
    threadErrors->currentErrorIdx = 0;

  //set the information
  ddocDebug(4, "addError", "Index: %d Error : %d at %s line %d, assertion %s", threadErrors->currentErrorIdx, code, fileName, line, assertion);
  threadErrors->ddocLastErrors[threadErrors->currentErrorIdx].code = code;
  threadErrors->ddocLastErrors[threadErrors->currentErrorIdx].fileName = fileName;
  threadErrors->ddocLastErrors[threadErrors->currentErrorIdx].line = line;
  threadErrors->ddocLastErrors[threadErrors->currentErrorIdx].assertion = assertion;

  //index at the end? Set the traceback mark to the beginning
  if(threadErrors->currentErrorIdx == ERROR_BUF_LENGTH - 1)
    resetError(&(threadErrors->ddocLastErrors[0]));
  else //set the traceback mark to the next position
    resetError(&(threadErrors->ddocLastErrors[threadErrors->currentErrorIdx + 1]));

  threadErrors->readErrorIdx = threadErrors->currentErrorIdx;
}
Esempio n. 12
0
void Triggerconf::deleteModule (string module)
{
	if (! existsModule (module)) return;

	DOMNode* currentModule = selectModule (module);
	if (currentModule == NULL)	return;
	
	rootnode->removeChild (currentModule);
	currentModule = NULL;

	resetError ();
}
Esempio n. 13
0
int main (int argc, char** argv) {
  struct gameState G;
  struct gameState previousG;
  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
           sea_hag, tribute, smithy};

  int seed = 2;
  int* test = malloc(last_tester * sizeof(int));
  createCompareStateArray(test,1);


  int i=0;
  int player = 0;
  signal(SIGALRM,timeout);
  signal(SIGSEGV,handle_segfault);

  printf("\n-------------------- Testing TEST_NAME --------------------\n\n");
  for (i = 1; i <= 1; i++){ //for some fuzzing, set seed to i
    resetError();
    initTestGame(2, k, seed, &G);

    
    if (whoseTurn(&G) == 0) {
      player = 0;
	  /***************************************************
		
  	  ***************************************************/
      printf("TEST1: \n");
      alarm(2);
      //TEST CASE HERE 
      alarm(0);
      printResults();
      resetError();

    }
    
  } // end of main for
  printf(">>>>>>>>>>> SUCCESS: Testing TEST_NAME complete <<<<<<<<<<<\n\n");
  return 0;
}
Esempio n. 14
0
ConfigRetriever::ConfigRetriever(const char * _connect_string,
                                 int force_nodeid,
				 Uint32 version,
                                 ndb_mgm_node_type node_type,
				 const char * _bindaddress,
                                 int timeout_ms) :
  m_end_session(true),
  m_version(version),
  m_node_type(node_type)
{
  DBUG_ENTER("ConfigRetriever::ConfigRetriever");
  DBUG_PRINT("enter", ("connect_string: '%s', force_nodeid: %d",
                       _connect_string, force_nodeid));
  DBUG_PRINT("enter", ("version: %d, node_type: %d, bind: %s, timeout: %d",
                       version, node_type,_bindaddress, timeout_ms));

  m_handle= ndb_mgm_create_handle();

  if (m_handle == 0) {
    setError(CR_ERROR, "Unable to allocate mgm handle");
    DBUG_VOID_RETURN;
  }

  ndb_mgm_set_timeout(m_handle, timeout_ms);

  if (ndb_mgm_set_connectstring(m_handle, _connect_string))
  {
    BaseString tmp(ndb_mgm_get_latest_error_msg(m_handle));
    tmp.append(" : ");
    tmp.append(ndb_mgm_get_latest_error_desc(m_handle));
    setError(CR_ERROR, tmp.c_str());
    DBUG_VOID_RETURN;
  }

  if (force_nodeid &&
      ndb_mgm_set_configuration_nodeid(m_handle, force_nodeid))
  {
    setError(CR_ERROR, "Failed to set forced nodeid");
    DBUG_VOID_RETURN;
  }

  if (_bindaddress)
  {
    if (ndb_mgm_set_bindaddress(m_handle, _bindaddress))
    {
      setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
      DBUG_VOID_RETURN;
    }
  }
  resetError();
  DBUG_VOID_RETURN;
}
Esempio n. 15
0
bool WorldCustom::toFile()
{
	cout << "To file: " << file << endl;
	resetError();
	Writer* writer = new Writer(file.c_str());
	if (writer && writer->Open())
	{
		try
		{
			writer->writeMultipleFormats("[Continents=%u]\n", continentsVector->size());
			for (int i = 0; i < continentsVector->size(); i++)
				writer->writeMultipleFormats("%n=%u,%u\n", continentsVector->at(i)->getName(), continentsVector->at(i)->getRegistryValue(), continentsVector->at(i)->getControlValue());
			//cout << countriesVector->at(0)->getName();
			//cout << continentsVector->at(0)->getName();
			writer->writeMultipleFormats("[Territories=%u]\n", countriesVector->size());
			for (int i = 0; i < countriesVector->size(); i++)
				writer->writeMultipleFormats("%n=%u\n", countriesVector->at(i)->getName().c_str(), countriesVector->at(i)->getRegistryValue());
			writer->writeMultipleFormats("[Links=%u]\n", numberOfLinks);
			for (int i = 0, j = 0; i < (int)countriesVector->size(); i++)
			{
				writer->writeMultipleFormats("%u,%u,%u,%u,", countriesVector->at(i)->getRegistryValue(), countriesVector->at(i)->getPositionX(), countriesVector->at(i)->getPositionY(), countriesVector->at(i)->getContinent()->getRegistryValue());
				for (j = 0; j < (int)countriesVector->at(i)->getConnectedCountries()->size(); j++)
				{
					writer->writeNextPosSignedINT32(countriesVector->at(i)->getConnectedCountries()->at(j)->getRegistryValue());
					if (j == countriesVector->at(i)->getConnectedCountries()->size() - 1)
						writer->writeNextByte('\n');
					else
						writer->writeNextByte(',');
				}
			}
			writer->writeNextByte('\n');
		}
		//The data sent to the writer was corrupted.
		catch (DataNotGood dng) {
			setError(dng.what());
			return false;
		}
		//File does not respond.
		catch (fileNotGood fng) {
			setError(fng.what());
			return false;
		}
		//Close the file whatever happened not to loose data.
		writer->Close();

		return true;
	}
	else
		setError("Could not open the output file.");
	return false;
}
Esempio n. 16
0
File: BWSL.cpp Progetto: tinco/bwapi
 //----------------------------------- CONNECT ---------------------------------------------------
 BWSL_EXPORT bool connect()
 {
   resetError();
   try
   {
     return BWAPI::connect();
   }
   catch(GeneralException &)
   {
     lastError = Errors::Connection_Failure;
     return 0;
   }
   return 1;
 }
Esempio n. 17
0
void Triggerconf::setConfigValue (string module, string submodule, string configname, string value)
{
	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;
	
	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;
	
	XMLCh* xval		= XMLString::transcode (value.c_str ());
	elem->setTextContent	(xval);
	XMLString::release	(&xval);

	resetError ();
}
Esempio n. 18
0
void Triggerconf::createModule (string module)
{
	if (rootnode == NULL) return;
	
	if (existsModule (module)) {
		resetError ();	
		return;
	}

	XMLCh* xmodulename	= XMLString::transcode (ELEMENT_MODULE_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xmodulename);
	XMLString::release	(&xmodulename);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xmodule		= XMLString::transcode (module.c_str ());
	node->setAttribute	(xattrname, xmodule);

	XMLString::release	(&xattrname);
	XMLString::release	(&xmodule);

	rootnode->appendChild (node);

	resetError ();
}
Esempio n. 19
0
void Triggerconf::deleteConfigElement (string module, string submodule, string configname)
{
	if (! existsConfigElement (module, submodule, configname)) return;

	DOMNode* currentSubmodule = selectSubmodule (module, submodule);
	if (currentSubmodule == NULL) return;

	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;

	currentSubmodule->removeChild (currentConfigElement);
	currentConfigElement = NULL;

	resetError ();
}
Esempio n. 20
0
void Triggerconf::deleteConfigAttribute (string module, string submodule, string configname, string attributename)
{
	if (! existsConfigElement (module, submodule, configname)) return;

	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;

	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;

	XMLCh* xattrname	= XMLString::transcode (attributename.c_str ());
	elem->removeAttribute	(xattrname);
	XMLString::release	(&xattrname);

	resetError ();
}
SEXP getPlatformInfo(SEXP sPlatformID){
    resetError("ROpenCL::getPlatformInfo");
    static char cBuffer[1024];
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    std::string str;
    Rcpp::List result;
    
#ifdef CL_PLATFORM_PROFILE /* TODO CHECK THIS IS STRING RETURN VALUE */
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_PROFILE, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_PROFILE"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_VERSION
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_VERSION"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_NAME
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo (*platformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_NAME"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_VENDOR
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_VENDOR, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    result["CL_PLATFORM_VENDOR"] = Rcpp::wrap(str);
#endif
#ifdef CL_PLATFORM_EXTENSIONS
    cBuffer[0] = '\0';
    logError( clGetPlatformInfo(*platformID, CL_PLATFORM_EXTENSIONS, sizeof(cBuffer), cBuffer, NULL) );
    str = cBuffer;
    std::string word;
    std::stringstream ss(str); // Insert the string into a stream
    Rcpp::List extensions;
    while (ss >> word) { // Fetch next word from stream
        extensions.push_back(Rcpp::wrap(word));
    }
    result["CL_PLATFORM_EXTENSIONS"] = Rcpp::wrap(extensions);
#endif

    PRINTONERROR();
    return result;
}
Esempio n. 22
0
void clearLCD(){

   /* clear the stack */
   clearStack();

   /* reset any error string */
   resetError();

   /* clear the entry buffer */
   cancelEditor();

   /* re-initialize (and clear) the undo system */
   initUndoSystem();

   /* redraw the window */
   calcStackLCD();
   drawStackLCD();
}
SEXP getPlatformIDs(){
    //returns a list of platform ids
    resetError("ROpenCL::getPlatformIDs");
    cl_uint num_platforms = 0;
    logError( clGetPlatformIDs(0, 0, &num_platforms) );
    std::vector<cl_platform_id> platforms(num_platforms);
    logError( clGetPlatformIDs(num_platforms, platforms.empty() ? NULL : &platforms.front(), &num_platforms) );
    //for each platform in platforms add its pointer to the return list
    Rcpp::List result(platforms.size());
    for (int i=0; i<platforms.size(); i++){
        cl_platform_id *tempPlatformID = new cl_platform_id;
        *tempPlatformID = platforms[i];
         Rcpp::XPtr<cl_platform_id> tempXPtr(tempPlatformID);
        result[i] = tempXPtr;
    }
    PRINTONERROR();
    return result;
}
Esempio n. 24
0
File: BWSL.cpp Progetto: tinco/bwapi
  //----------------------------------- TAKE OVER -------------------------------------------------
  BWSL_EXPORT bool takeover(AIModule& aiModule)
  {
    resetError();
    try
    {
      for(;;)
      {
        BWAPI::CallTypeId purpose = BWAPI::waitForEvent();

        // react upon bridge state
        switch(purpose)
        {
        case BWAPI::CallTypeIds::OnFrame:
          {
            if (BWAPI::getStaticGameData()->isOnMatchStart)
            {
              Game::onStart();
              aiModule.onStart();
            }
            if (!BWAPI::getStaticGameData()->userInput.isEmpty())
            {
              std::string text(BWAPI::getStaticGameData()->userInput.c_str());
              aiModule.onSendText(text);
            }
            // TODO: implement
            //BWAPI::GetUserInput()
            //aiModule.onSendText(input);
            Game::onFrame();
            aiModule.onFrame();
          }break;
        case BWAPI::CallTypeIds::OnDisconnect:
          {
          }return true;
        
        }
      }
    }
    catch(GeneralException &)
    {
      lastError = Errors::Connection_Failure;
      return false;
    }
    return true;
  }
Esempio n. 25
0
string Triggerconf::getConfigValue (string module, string submodule, string configname)
{
	if (existsConfigElement (module, submodule, configname) == false) {
		setError ("invalid config element");	
		return "";
	}

	DOMNode* node = selectConfigElement (module, submodule, configname);
	if (node == NULL) return "";

	const XMLCh* xval	= node->getTextContent ();
	char*	charstring	= XMLString::transcode (xval);
	string	ret		= charstring;
	XMLString::release	(&charstring);

	resetError ();

	return ret;
}
SEXP getCPUDeviceIDs(SEXP sPlatformID){
    resetError("ROpenCL::getCPUDeviceIDs");
    Rcpp::XPtr<cl_platform_id> platformID(sPlatformID);
    cl_uint num_devices = 0;

    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_CPU, 0, 0, &num_devices) );
    std::vector<cl_device_id> devices(num_devices);
    logError( clGetDeviceIDs(*platformID, CL_DEVICE_TYPE_CPU, num_devices, devices.empty() ? NULL : &devices.front(), &num_devices) );
    //for each platform in platforms add its pointer to the return list
    Rcpp::List result(devices.size());
    for (int i=0; i<devices.size(); i++){
        cl_device_id *tempDeviceID = new cl_device_id;
        *tempDeviceID = devices[i];
        Rcpp::XPtr<cl_device_id> tempXPtr(tempDeviceID);
        result[i] = tempXPtr;
    }
    PRINTONERROR();
    return result;
}
ConfigRetriever::ConfigRetriever(const char * _connect_string,
				 Uint32 version, Uint32 node_type,
				 const char * _bindaddress,
                                 int timeout_ms)
{
  DBUG_ENTER("ConfigRetriever::ConfigRetriever");

  m_version = version;
  m_node_type = node_type;
  _ownNodeId= 0;
  m_end_session= true;

  m_handle= ndb_mgm_create_handle();

  if (m_handle == 0) {
    setError(CR_ERROR, "Unable to allocate mgm handle");
    DBUG_VOID_RETURN;
  }

  ndb_mgm_set_timeout(m_handle, timeout_ms);

  if (ndb_mgm_set_connectstring(m_handle, _connect_string))
  {
    BaseString tmp(ndb_mgm_get_latest_error_msg(m_handle));
    tmp.append(" : ");
    tmp.append(ndb_mgm_get_latest_error_desc(m_handle));
    setError(CR_ERROR, tmp.c_str());
    DBUG_VOID_RETURN;
  }

  if (_bindaddress)
  {
    if (ndb_mgm_set_bindaddress(m_handle, _bindaddress))
    {
      setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
      DBUG_VOID_RETURN;
    }
  }
  resetError();
  DBUG_VOID_RETURN;
}
Esempio n. 28
0
void Triggerconf::createConfigAttribute	(string module, string submodule, string configname, string attributename)
{
	//
	// attributes are always created, no matter if they exists or not
	// dublication is prevented by xercesc
	//

	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;
	
	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;

	XMLCh* xattrname	= XMLString::transcode (attributename.c_str ());
	XMLCh* xempty		= XMLString::transcode ("");
	elem->setAttribute	(xattrname, xempty);
	XMLString::release	(&xattrname);
	XMLString::release	(&xempty);

	resetError ();
}
Esempio n. 29
0
void Triggerconf::deleteAllModules ()
{
	//
	// removed all modules. have to iterate over and over again
	// if we removed an item because the nodes reflect live changes
	// and removing an element changes the child count
	//
	
	if (rootnode == NULL) return;	
	resetError ();

	DOMNodeList* childs = rootnode->getChildNodes ();
	if (childs == NULL) return;

	bool removed;

	do {
		removed = false;

		for (unsigned int i=0; i<childs->getLength (); i++) {
			
			DOMNode* child = childs->item (i);
			if (child == NULL) continue;
			
			if (child->getNodeType () == DOMNode::ELEMENT_NODE || 
					child->getNodeType () == DOMNode::TEXT_NODE) {
	
				rootnode->removeChild (child);
				removed = true;
				break;
			}
	
		} // for (unsigned int i=0; i<childs->getLength (); i++)

	} while (removed); 

	assert (getModuleNames().size() == 0);
}
Esempio n. 30
0
string Triggerconf::getSubmoduleAttributeValue (string module, string submodule, string attributename)
{
	if (! existsSubmodule (module, submodule)) {
		setError ("invalid submodule");
		return "";
	}

	DOMNode* node = selectSubmodule (module, submodule);
	assert (node->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) node;
	
	XMLCh*	xattrname	= XMLString::transcode (attributename.c_str ());
	const XMLCh* xattrval	= elem->getAttribute (xattrname);
	char*	charstring	= XMLString::transcode (xattrval);
	string	ret		= charstring;

	XMLString::release	(&xattrname);
	XMLString::release	(&charstring);

	resetError		();

	return ret;
}