Exemplo n.º 1
0
    void ConnectedModules::addModule(const ModuleDescriptor& md, ConnectedModule* module) {
        Lock l(m_modulesMutex);

        // Store modules including identifier.
        stringstream sstr;
        sstr << md.getName() << "-" << md.getIdentifier();
        const string s = sstr.str();

        m_modules[s] = module;
    }
Exemplo n.º 2
0
    void ConnectedModules::removeModule(const ModuleDescriptor& md) {
        Lock l(m_modulesMutex);

        // Remove module including identifier.
        stringstream sstr;
        sstr << md.getName() << "-" << md.getIdentifier();
        const string s = sstr.str();

        m_modules.erase(s);
    }
Exemplo n.º 3
0
    bool ConnectedModules::hasModule(const ModuleDescriptor& md) {
        Lock l(m_modulesMutex);

        // Find module including identifier.
        stringstream sstr;
        sstr << md.getName() << "-" << md.getIdentifier();
        const string s = sstr.str();

        return (m_modules.count(s) != 0);
    }
Exemplo n.º 4
0
GMAC_API void APICALL __cudaRegisterTexture(void **fatCubinHandle, const struct textureReference *hostVar,
		const void ** /*deviceAddress*/, const char *deviceName, int /*dim*/, int /*norm*/, int /*ext*/)
{
    TRACE(GLOBAL, "CUDA Texture");
	ModuleDescriptor *mod = (ModuleDescriptor *)fatCubinHandle;
	ASSERTION(mod != NULL);
	enterGmac();
    TextureDescriptor t = __impl::cuda::hpe::TextureDescriptor(deviceName, hostVar);
	mod->add(t);
	exitGmac();
}
Exemplo n.º 5
0
const char *ModuleDescriptor::GetName(uint16_t cid, uint16_t id)
{
    noname[0] = 0;
    ModuleDescriptor *m = ModuleDescriptor::Config[cid][id];

    if (m == NULL) {
        return noname;
    } else {
        return m->getName();
    }
}
Exemplo n.º 6
0
GMAC_API void APICALL __cudaRegisterVar(void **fatCubinHandle, char *hostVar,
		char * deviceAddress, const char *deviceName, int /*ext*/, int /*size*/,
		int constant, int /*global*/)
{
    TRACE(GLOBAL, "CUDA Variable %s: %p", deviceName, deviceAddress);
	ModuleDescriptor *mod = (ModuleDescriptor *)fatCubinHandle;
	ASSERTION(mod != NULL);
	enterGmac();
    VariableDescriptor v = __impl::cuda::hpe::VariableDescriptor(deviceName, hostVar, bool(constant != 0));
    mod->add(v);
	exitGmac();
}
Exemplo n.º 7
0
GMAC_API void APICALL __cudaRegisterFunction(
		void **fatCubinHandle, const char *hostFun, char * /*devFun*/,
		const char *devName, int /*threadLimit*/, uint3 * /*tid*/, uint3 * /*bid*/,
		dim3 * /*bDim*/, dim3 * /*gDim*/)
{
    TRACE(GLOBAL, "CUDA Function");
	ModuleDescriptor *mod = (ModuleDescriptor *)fatCubinHandle;
	ASSERTION(mod != NULL);
	enterGmac();
    KernelDescriptor k = __impl::core::hpe::KernelDescriptor(devName, (gmac_kernel_id_t) hostFun);
    mod->add(k);
	exitGmac();
}
Exemplo n.º 8
0
void EdgeKiller::onModuleUnload(
        S2EExecutionState* state,
        const ModuleDescriptor &module
        )
{
    DECLARE_PLUGINSTATE(EdgeKillerState, state);

    //Remove all the polling entries that belong to the module
    EdgeKillerState::EdgeEntries &entries =
            plgState->getEntries();

    EdgeKillerState::EdgeEntries::iterator it1, it2;

    it1 = entries.begin();
    while(it1 != entries.end()) {
        const EdgeKillerState::Edge &e = *it1;
        if (module.Contains(e.source)) {
            it2 = it1;
            ++it2;
            entries.erase(it1);
            it1 = it2;
        }else {
            ++it1;
        }
    }
}
    KeyValueConfiguration GlobalConfigurationProvider::getConfiguration(const ModuleDescriptor& md) {
        Lock l(m_configurationMutex);

        if ( (md.getName() == "Monitor") || (md.getName() == "Cockpit") ) {
            return m_configuration;
        }

        // Determine subset of configuration for this client.
        KeyValueConfiguration globalConfiguration = m_configuration.getSubsetForSection("global.");

        stringstream module;
        module << md.getName() << ".";
        KeyValueConfiguration privateConfigurationBasedOnModuleName = m_configuration.getSubsetForSection(module.str());

        KeyValueConfiguration privateConfigurationBasedOnModuleIdentifier;
        if (md.getIdentifier() != "") {
            stringstream moduleIdentifier;
            moduleIdentifier << md.getName() << ":" << md.getIdentifier() << ".";
            KeyValueConfiguration privateConfigurationBasedOnModuleIdentiferIncludingModuleIdentifier;
            privateConfigurationBasedOnModuleIdentiferIncludingModuleIdentifier = m_configuration.getSubsetForSection(moduleIdentifier.str());

            // Remove string ":" + md.getIdentifier().
            const vector<string> keys = privateConfigurationBasedOnModuleIdentiferIncludingModuleIdentifier.getListOfKeys();
            vector<string>::const_iterator it = keys.begin();
            stringstream moduleIdentifierPart;
            moduleIdentifierPart << ":" << md.getIdentifier() << ".";
            stringstream sstrPrivateConfigurationWithoutModuleIdentifier;
            while (it != keys.end()) {
                string key = (*it++);

                stringstream modifiedKey;
                modifiedKey << key.substr(0, key.find(moduleIdentifierPart.str())) << "." << key.substr(key.find(moduleIdentifierPart.str()) + moduleIdentifierPart.str().length());

                sstrPrivateConfigurationWithoutModuleIdentifier << modifiedKey.str() << "=" << privateConfigurationBasedOnModuleIdentiferIncludingModuleIdentifier.getValue<string>(key) << endl;
            }
            if (sstrPrivateConfigurationWithoutModuleIdentifier.str().length() > 0) {
                privateConfigurationBasedOnModuleIdentifier.readFrom(sstrPrivateConfigurationWithoutModuleIdentifier);
            }
        }

        // Prepare configuration.
        stringstream configurationForClient;
        globalConfiguration.writeTo(configurationForClient);
        configurationForClient << endl;

        privateConfigurationBasedOnModuleName.writeTo(configurationForClient);
        configurationForClient << endl;

        privateConfigurationBasedOnModuleIdentifier.writeTo(configurationForClient);
        configurationForClient << endl;

        KeyValueConfiguration clientKeyValueConfiguration;
        clientKeyValueConfiguration.readFrom(configurationForClient);

        // Set up configuration object.
        return clientKeyValueConfiguration;
    }
Exemplo n.º 10
0
    void SuperComponent::handleChangeState(const ModuleDescriptor& md, const coredata::dmcp::ModuleStateMessage::ModuleState &ms) {
        string state;
        switch (ms) {
            case coredata::dmcp::ModuleStateMessage::NOT_RUNNING: state = "NOT_RUNNING"; break;
            case coredata::dmcp::ModuleStateMessage::RUNNING: state = "RUNNING"; break;
            case coredata::dmcp::ModuleStateMessage::UNDEFINED_STATE: state = "UNDEFINED_STATE"; break;
        }

        CLOG1 << "[odsupercomponent]: Module " << md.toString() << " changed state to " << state << endl;

        if (m_modules.hasModule(md)) {
            m_modules.getModule(md)->setState(ms);
        }
    }
Exemplo n.º 11
0
void ModuleDescriptor::Init(uint8_t hostID)
{
    ModuleDescriptor *md;

    for (uint32_t i = 0; i < ModuleDescriptor::Config.count(); i++) // resolve host names into NID
        for (uint32_t j = 0; j < ModuleDescriptor::Config[i].count(); j++) {
            Node::Get()->trace(Node::EXECUTION) << "> Info: Module init '" << ModuleDescriptor::Config[i][j]->getName() << "' for host '" << ModuleDescriptor::Config[i][j]->hostName << "'" << std::endl;

            if (stricmp(ModuleDescriptor::Config[i][j]->hostName, Node::Get()->name()) == 0 ||
                    stricmp(ModuleDescriptor::Config[i][j]->hostName, "local") == 0) {
                md = ModuleDescriptor::Config[i][j];
                ModuleDescriptor::Main[hostID][i][j] = md;
                md->hostID = hostID;
                md->applyInitialProjections(hostID);

                if (md->module != NULL) {
                    md->module->_start();
                }

                ModuleDescriptor::Config[i][j] = NULL;
            }
        }
}
Exemplo n.º 12
0
void FunctionMonitorState::disconnect(const ModuleDescriptor &desc, CallDescriptorsMap &descMap)
{
    CallDescriptorsMap::iterator it = descMap.begin();
    while (it != descMap.end()) {
        uint64_t addr = (*it).first;
        const CallDescriptor &call = (*it).second;
        if (desc.Contains(addr) && desc.Pid == call.pid) {
            CallDescriptorsMap::iterator it2 = it;
            ++it;
            descMap.erase(it2);
        }else {
            ++it;
        }
    }
}
Exemplo n.º 13
0
 void SuperComponent::handleConnectionLost(const ModuleDescriptor& md) {
     // This methods is called when a module terminates not properly.
     if (m_modules.hasModule(md)) {
         CLOG1 << "[odsupercomponent]: Connection to module " << md.toString() << " lost" << endl;
         ConnectedModule* module = m_modules.getModule(md);
         m_modules.removeModule(md);
         m_shutdownModules.addModule(md, module);
     }
     else {
         if (m_shutdownModules.hasModule(md)) {
             if (!m_shutdownModules.getModule(md)->hasExitCode()) {
                 clog << "[odsupercomponent]: Something went wrong...lost connection to module " << md.toString();
                 clog << ", module is in shutdownModule list but has not set an ExitCode." << endl;
             }
         }
     }
 }
Exemplo n.º 14
0
    void SuperComponent::handleExitCode(const ModuleDescriptor& md, const coredata::dmcp::ModuleExitCodeMessage::ModuleExitCode &me) {
        string exitcode;
        switch (me) {
            case coredata::dmcp::ModuleExitCodeMessage::OKAY: exitcode = "OKAY"; break;
            case coredata::dmcp::ModuleExitCodeMessage::EXCEPTION_CAUGHT: exitcode = "EXCEPTION_CAUGHT"; break;
            case coredata::dmcp::ModuleExitCodeMessage::SERIOUS_ERROR: exitcode = "SERIOUS_ERROR"; break;
            case coredata::dmcp::ModuleExitCodeMessage::CONNECTION_LOST: exitcode = "CONNECTION_LOST"; break;
            case coredata::dmcp::ModuleExitCodeMessage::NO_SUPERCOMPONENT: exitcode = "NO_SUPERCOMPONENT"; break;
            case coredata::dmcp::ModuleExitCodeMessage::UNDEFINED_EXITCODE: exitcode = "UNDEFINED_EXITCODE"; break;
        }

        CLOG1 << "[odsupercomponent]: Module " << md.toString() << " shutdown with exitcode " << exitcode << endl;

        if (m_modules.hasModule(md)) {
            ConnectedModule* module = m_modules.getModule(md);
            m_modules.removeModule(md);
            module->setExitCode();
            m_shutdownModules.addModule(md, module);
        }
    }
Exemplo n.º 15
0
    void SuperComponent::handleRuntimeStatistics(const ModuleDescriptor& md, const coredata::dmcp::RuntimeStatistic& rs) {
        Lock l(m_moduleStatisticsMutex);

        ModuleStatistic entry(md, rs);
        m_moduleStatistics.putTo_MapOfModuleStatistics(md.getName(), entry);
    }
Exemplo n.º 16
0
 void SuperComponent::handleUnkownContainer(const ModuleDescriptor& md, const Container& container) {
     CLOG1 << "[odsupercomponent]: Received unknown container " << container.toString() << "from " << md.toString() << endl;
 }
Exemplo n.º 17
0
ModuleDescriptor* ModuleDescriptor::getModule(const std::string& filename, map<string, string>& plugInIds)
{
   DynamicModule* pDynMod = Service<PlugInManagerServices>()->getDynamicModule(filename);
   if (pDynMod == NULL || !pDynMod->isLoaded())
   {
      return NULL;
   }

   // try a new style module first
   OpticksGetModuleDescriptorType pProcAddr =
      reinterpret_cast<OpticksGetModuleDescriptorType>(pDynMod->getProcedureAddress("opticks_get_module_descriptor"));
   if (pProcAddr != NULL)
   {
      struct OpticksModuleDescriptor* pDescriptor = pProcAddr(ConnectionManager::instance());
      if (pDescriptor != NULL)
      {
         VERIFY(pDescriptor->version >= MOD_TWO);
#if defined(WIN_API)
         if (pDescriptor->debug == DEBUG_BOOL)
         {
#endif
            ModuleDescriptor* pModule = new ModuleDescriptor(pDescriptor->pModuleId);
            FilenameImp fileObj(filename);
            pModule->mFileName = fileObj.getFullPathAndName();

            pModule->setName(pModule->mFileName);
            pModule->setDisplayText(filename);

            FileFinderImp find;
            find.findFile(fileObj.getPath(), fileObj.getFileName());
            find.findNextFile();
            pModule->mFileSize = find.getLength();

            find.getLastModificationTime(pModule->mFileDate);
            pModule->mDescription = "";
            pModule->mpModule = pDynMod;
            pModule->mModuleVersion = pDescriptor->version;
            pModule->mInstantiateSymbol = pDescriptor->pInstantiateSymbol;
            pModule->mCanCache = false;
            if (pDescriptor->version >= MOD_THREE)
            {
               pModule->mCanCache = pDescriptor->cacheable;
            }
            pModule->initializePlugInInformation(plugInIds);
            // pDescriptor is no longer valid at this point

            return pModule;
#if defined(WIN_API)
         }
         else
         {
            std::string errorMessage("Error loading plug-in from PlugIns folder. The plug-in was ");
            if (DEBUG_BOOL)
            {
               errorMessage += "built in release mode, but this a debug mode version of the application.";
            }
            else
            {
               errorMessage += "built in debug mode, but this a release mode version of the application.";
            }
            MessageResource message("PlugInError", "app", "8B5F1ADB-1210-406f-B961-72C2189CE84D");
            message->addProperty("message", errorMessage);
            message->addProperty("filename", filename);
            message->finalize();

            Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
            return NULL;
         }
#endif
      }
      else
      {
         std::string errorMessage("Error loading plug-in from PlugIns folder. The plug-in did not "
            "return the proper struct.");
         MessageResource message("PlugInError", "app", "B63EB55A-2881-4A2A-AE8B-C8FE7E9C4080");
         message->addProperty("message", errorMessage);
         message->addProperty("filename", filename);
         message->finalize();

         Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
         return NULL;
      }
   }

   // old style modules only supported on Solaris and Windows
#if defined(SOLARIS) || defined(WIN_API)
   // try an old style module
   // Check the module interface version
   int version = 0; // no module should ever have this version so it's a good "invalid" value
   int(*moduleVersionProcedure)() = reinterpret_cast<int(*)()>
      (pDynMod->getProcedureAddress( "opticks_get_module_interface_version" ));
   if (moduleVersionProcedure != NULL)
   {
      version = moduleVersionProcedure();
   }

   if (version != 1) // This is the currently expected version...it hardly changes so it's hardcoded
   {
      Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
      return NULL;
   }

   // below are the functions required for a version 1 module
   bool(*pInitProcedure)(External*) =
      reinterpret_cast<bool(*)(External*)>(pDynMod->getProcedureAddress("initialize_op"));
   bool(*pNameProcedure)(char**, char**, char**, unsigned int*, char**, char**) =
      reinterpret_cast<bool(*)(char**, char**, char**, unsigned int*, char**, char**)>(
                               pDynMod->getProcedureAddress("get_name"));
   DMPROC pInterfaceProc = pDynMod->getProcedureAddress("instantiate_interface");
   DMPROC pDestroyProc = pDynMod->getProcedureAddress("destroy_op");

   if (pInitProcedure == NULL || pNameProcedure == NULL || pInterfaceProc == NULL || pDestroyProc == NULL)
   {
      Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
      return NULL;
   }

   if (!pInitProcedure(ConnectionManager::instance()))
   {
      Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
      return NULL;
   }

   char* pModuleName = NULL;
   char* pModuleVersion = NULL;
   char* pModuleDescription = NULL;
   unsigned int totalPlugIns = 0;
   char* pModuleId = NULL;
   char* pValidationKey = NULL;
   if (!pNameProcedure(&pModuleName, &pModuleVersion, &pModuleDescription,
      &totalPlugIns, &pValidationKey, &pModuleId) || pModuleId == NULL)
   {
      Service<PlugInManagerServices>()->destroyDynamicModule(pDynMod);
      return NULL;
   }

   ModuleDescriptor* pModule = new ModuleDescriptor(string(pModuleId));
   FilenameImp fileObj(filename);
   pModule->mFileName = fileObj.getFullPathAndName();
   pModule->setName(pModule->mFileName);
   pModule->setDisplayText(filename);

   FileFinderImp find;
   find.findFile(fileObj.getPath(), fileObj.getFileName());
   find.findNextFile();
   pModule->mFileSize = find.getLength();

   find.getLastModificationTime(pModule->mFileDate);
   pModule->mVersion = pModuleVersion;
   pModule->mDescription = pModuleDescription;
   pModule->mPlugInTotal = totalPlugIns;
   pModule->mValidationKey = pValidationKey;
   pModule->mCanCache = false;
   pModule->mpModule = pDynMod;
   pModule->mModuleVersion = version;
   pModule->initializePlugInInformation(plugInIds);
  
   return pModule;
#else
   return NULL;
#endif
}
 bool ModuleDescriptorComparator::operator()(const ModuleDescriptor &m1, const ModuleDescriptor &m2) const {
     return m1.toString().compare(m2.toString()) < 0;
 }
Exemplo n.º 19
0
void TextureBuilder::fromJson(const QJsonObject &json) {

    if (!json["colorMap"].isNull() && !json["colorMap"].isUndefined())
        _colorMap = json["colorMap"].toString();
    if (!json["cloudMap"].isNull() && !json["cloudMap"].isUndefined())
        _cloudMap = json["cloudMap"].toString();
    if (!json["reflectionMap"].isNull() && !json["reflectionMap"].isUndefined())
        _reflectionMap = json["reflectionMap"].toString();
    if (!json["bumpMap"].isNull() && !json["bumpMap"].isUndefined())
        _bumpMap = json["bumpMap"].toString();

    if (!json["builderType"].isNull() && !json["builderType"].isUndefined()) {
        auto sType = json["builderType"].toString();
        if (sType.toLower() != "sphere" && sType.toLower() != "plane" && sType.toLower() != "cylinder")
            _builderType = "sphere";
        else
            _builderType = sType;
    }

    if (!json["size"].isNull() && !json["size"].isUndefined()) {
        auto a = json["size"].toArray();
        _size = std::tuple<int,int>(a[0].toInt(),a[1].toInt());
    }

    if (!json["bounds"].isNull() && !json["bounds"].isUndefined()) {
        auto a1 = json["bounds"].toArray();
        _bounds = std::tuple<double,double,double,double>(
            a1[0].toDouble(),
            a1[1].toDouble(),
            a1[2].toDouble(),
            a1[3].toDouble()
            );
    }

    if (!json["randomFactors"].isNull() && !json["randomFactors"].isUndefined()) {
        auto jsRf = json["randomFactors"];
        if (jsRf.isDouble()) {
            _randomFactors.clear();
            _randomFactors.append(jsRf.toDouble());
        }
        if (jsRf.isArray()) {
            _randomFactors.clear();
            QJsonArray arr = jsRf.toArray();
            for (auto h = 0; h < arr.size(); ++h) {
                _randomFactors.append(arr[h].toDouble());
            }
        }
    }


    QJsonArray aModules = json["modules"].toArray();
    QJsonArray aHeightMaps = json["heightMaps"].toArray();
    QJsonArray aHMBuilders = json["heightMapBuilders"].toArray();
    QJsonArray aRenderers = json["renderers"].toArray();
    QJsonArray aImages = json["images"].toArray();

    _modDesc.clear();
    _modules.clear();
    for (auto h = 0; h < aModules.size(); ++h) {
        ModuleDescriptor *m = new ModuleDescriptor();
        QJsonObject o = aModules[h].toObject();
        m->fromJson(o);

        QString name = m->name();
        m->setModules(_modules);
        QSharedPointer<ModuleDescriptor> p; p.reset(m);
        _modDesc.insert(name,p);
    }

    _rndDesc.clear();
    _renderers.clear();
    _rndNames.clear();

    for (auto h = 0; h < aRenderers.size(); ++h) {
        RendererDescriptor *m = new RendererDescriptor();
        QJsonObject o = aRenderers[h].toObject();
        m->fromJson(o);
        QString name = m->name();

        m->setImages(_images);
        m->setNoiseMaps(_heightMaps);
        m->setRenderers(_renderers);

        QSharedPointer<RendererDescriptor> p; p.reset(m);
        _rndDesc.insert(name,p);
        _rndNames.append(name);
    }

    _nmbDesc.clear();
    _noiseMapBuilders.clear();
    for (auto h = 0; h < aHMBuilders.size(); ++h) {
        NoiseMapBuilderDescriptor *m = new NoiseMapBuilderDescriptor();
        QJsonObject o = aHMBuilders[h].toObject();

        m->fromJson(o);

        assignSizeInfoToNMBDesc(m);

        //m->setBuilderType(NoiseMapBuilderType::SPHERE);
        //m->setSize(std::get<0>(_size), std::get<1>(_size));
        //m->setBounds(std::get<0>(_bounds),std::get<1>(_bounds),std::get<2>(_bounds),std::get<3>(_bounds));

        m->setModules(_modules);

        QString name = m->name();
        QSharedPointer<NoiseMapBuilderDescriptor> p; p.reset(m);
        _nmbDesc.insert(name,p);
    }

    _hmDesc.clear();
    _heightMaps.clear();
    for (auto h = 0; h < aHeightMaps.size(); ++h) {
        HeightMapDescriptor *m = new HeightMapDescriptor();
        QString o = aHeightMaps[h].toString();

        m->setName(o);

        QSharedPointer<HeightMapDescriptor> p; p.reset(m);
        _hmDesc.insert(o,p);
    }

    _images.clear();
    __imDesc.clear();
    for (auto h = 0; h < aImages.size(); ++h) {
        ImageDescriptor *m = new ImageDescriptor();
        QString o = aImages[h].toString();

        m->setName(o);
        if (h == 0 && _colorMap == "") _colorMap = o;
        if (h == 1 && _bumpMap == "") _bumpMap =  o;
        if (h == 2 && _cloudMap == "") _cloudMap = o;
        if (h == 3 && _reflectionMap == "") _reflectionMap = o;

        QSharedPointer<ImageDescriptor> p; p.reset(m);
        __imDesc.insert(o,p);
    }

    /*
    createAll();
    connectAll();
    */
}
Exemplo n.º 20
0
 void ConnectedModules::addModule(const ModuleDescriptor& md, ConnectedModule* module) {
     Lock l(m_modulesMutex);
     m_modules[md.getName()] = module;
 }
Exemplo n.º 21
0
 void ConnectedModules::removeModule(const ModuleDescriptor& md) {
     Lock l(m_modulesMutex);
     m_modules.erase(md.getName());
 }
Exemplo n.º 22
0
 bool ConnectedModules::hasModule(const ModuleDescriptor& md) {
     Lock l(m_modulesMutex);
     return (m_modules.count(md.getName()) != 0);
 }