Beispiel #1
0
sortStatus_t LoadSortModule(sortEngine_d* engine, const char* path, 
	int numThreads, int valuesPerThread, int valueCode, bool transList, 
	std::auto_ptr<sortEngine_d::SortKernel>* sort) {

	std::auto_ptr<sortEngine_d::SortKernel> s(new sortEngine_d::SortKernel);

	std::ostringstream oss;
	oss<< path<< "sort_"<< numThreads<< "_"<< valuesPerThread<< "_";
	switch(valueCode) {
		case 0: oss<< "key"; break;
		case 1: oss<< "index"; break;
		case 2: oss<< "single"; break;
		case 3: oss<< "multi"; break;
	}
	oss<< "_"<< (transList ? "list" : "simple")<< ".cubin";
	
	CUresult result = engine->context->LoadModuleFilename(oss.str(), 
		&s->module);
	if(CUDA_SUCCESS != result) return SORT_STATUS_KERNEL_NOT_FOUND;
	
	bool success = LoadFunctions("RadixSort", numThreads, s->module, 
		s->functions);
	if(!success) return SORT_STATUS_KERNEL_ERROR;

	success = LoadFunctions("RadixSort_ee", numThreads, s->module, 
		s->eeFunctions);
	if(!success) return SORT_STATUS_KERNEL_ERROR;

	*sort = s;
	return SORT_STATUS_SUCCESS;
}
Beispiel #2
0
sortStatus_t LoadHistModule(sortEngine_d* engine, const char* path, 
	bool transList, std::auto_ptr<sortEngine_d::HistKernel>* hist) {

	std::auto_ptr<sortEngine_d::HistKernel> h(new sortEngine_d::HistKernel);

	std::ostringstream oss;
	oss<< path<< "hist_"<< (transList ? "list" : "simple") << ".cubin";

	CUresult result = engine->context->LoadModuleFilename(oss.str(),
		&h->module);
	if(CUDA_SUCCESS != result) return SORT_STATUS_KERNEL_NOT_FOUND;

	bool success = LoadFunctions("HistogramReduce_1", NumHistThreads, 
		h->module, h->pass1);
	if(success) 
		success = LoadFunctions("HistogramReduce_2", NumHistThreads, h->module,
			h->pass2);
	if(success) 
		success = LoadFunctions("HistogramReduce_3", NumHistThreads, h->module, 
			h->pass3);
	if(!success) return SORT_STATUS_KERNEL_ERROR;

	*hist = h;
	return SORT_STATUS_SUCCESS;
}
Beispiel #3
0
CConverter::CConverter(LPCSTR pszLibName, CFrameWnd* pWnd) : CTrackFile(pWnd)
{
	USES_CONVERSION;
	m_hBuff = NULL;
	m_pBuf = NULL;
	m_nBytesAvail = 0;
	m_nBytesWritten = 0;
	m_nPercent = 0;
	m_hEventFile = NULL;
	m_hEventConv = NULL;
	m_bDone = TRUE;
	m_bConvErr = FALSE;
	m_hFileName = NULL;
	OFSTRUCT ofs;
	if (OpenFile(pszLibName, &ofs, OF_EXIST) == HFILE_ERROR)
	{
		m_hLibCnv = NULL;
		return;
	}
	m_hLibCnv = LoadLibraryA(pszLibName);
	if (m_hLibCnv < (HINSTANCE)HINSTANCE_ERROR)
		m_hLibCnv = NULL;
	else
	{
		LoadFunctions();
		ASSERT(m_pInitConverter != NULL);
		if (m_pInitConverter != NULL)
		{
			CString str = AfxGetAppName();
			str.MakeUpper();
			VERIFY(m_pInitConverter(AfxGetMainWnd()->GetSafeHwnd(), T2CA(str)));
		}
	}
}
Beispiel #4
0
/**
 * Intializes the hardware.
 * Typically we access and initialize hardware at this point.
 * Device properties are typically created here as well.
 * Required by the MM::Device API.
 */
int MUCamSource::Initialize()
{
    if (!LoadFunctions())
        return DEVICE_ERR;
    if (initialized_)
        return DEVICE_OK;

    // set property list
    // -----------------
    FindMoticCameras();
    if(cameraCnt_ == 0)
    {
        return ERR_NO_CAMERAS_FOUND;
    }

    currentCam_ = 0;//MIDP_GetCurCameraIndex();
    int ret;
    CPropertyAction* pAct;
    if (!OpenCamera(hCameras_[currentCam_])) return DEVICE_ERR;
    char sName[Camera_Name_Len];
    GetMotiCamNAME(hCameras_[currentCam_], sName);
    //memcpy(sName, GetMotiCamNAME(hCameras_[currentCam_]), Camera_Name_Len);
    pAct = new CPropertyAction(this, &MUCamSource::OnDevice);
    ret = CreateProperty(g_Keyword_Cameras, sName, MM::String, true, pAct);
    ret = SetAllowedValues(g_Keyword_Cameras, DevicesVec_);
    assert(ret == DEVICE_OK);
    
    ret = InitDevice();
    if(ret == DEVICE_OK)
    {
        initialized_ = true;
    }

    return ret;
}
 HINSTANCE Load() {
     if (_library == NULL) {
         _library = LoadLibrary(TEXT("gpsapi"));
         
         if (_library != NULL) {
             LoadFunctions(_library);
         }
     }
     
     return _library;
 }
Beispiel #6
0
int LoadPropFuncByConfigfile(const gboolean first_load)
{
#ifdef _UI_DEBUG
	PrintTime();
#endif
	if(g_config_file_data != NULL){
		DealSpecialWidget(g_config_file_data->special_list);
	}
#ifdef _UI_DEBUG
	PrintTime();
#endif
        LoadFunctions(first_load);
	return 0;
}
Beispiel #7
0
sortStatus_t LoadCountModule(sortEngine_d* engine, const char* path, 
	std::auto_ptr<sortEngine_d::CountKernel>* count) {

	std::auto_ptr<sortEngine_d::CountKernel> c(new sortEngine_d::CountKernel);

	std::ostringstream oss;
	oss<< path<< "count.cubin";
	
	CUresult result = engine->context->LoadModuleFilename(oss.str(), 
		&c->module);
	if(CUDA_SUCCESS != result) return SORT_STATUS_KERNEL_NOT_FOUND;
	
	bool success = LoadFunctions("CountBuckets", NumCountThreads, c->module,
		c->functions);
	if(!success) return SORT_STATUS_KERNEL_ERROR;

	success = LoadFunctions("CountBuckets_ee", NumCountThreads, c->module, 
		c->eeFunctions);
	if(!success) return SORT_STATUS_KERNEL_ERROR;

	*count = c;
	return SORT_STATUS_SUCCESS;
}
Beispiel #8
0
static int vmware_init (void)
{
  if (!LoadFunctions()) {
    ERROR ("vmware guest plugin: Unable to load GuistLib functions");
    return (-1);
  }

  /* Try to load the library. */
  glError = GuestLib_OpenHandle(&glHandle);
  if (glError != VMGUESTLIB_ERROR_SUCCESS) {
     ERROR ("OpenHandle failed: %s", GuestLib_GetErrorText(glError));
     return (-1);
  }

  return (0);
}
Beispiel #9
0
void GLContext::CreateContext()
{
	// Create a temporary Opengl 2.1 context to allow the loading of functions that can create a 4.5 context
	auto tempContext = wglCreateContext(m_hDeviceContext);
	wglMakeCurrent(m_hDeviceContext, tempContext);

	if (!s_bLoadedFunctions)
	{
		LoadFunctions();
	}

	if (!s_bLoadedFunctions)
	{
		// TODO: Decide if crash or allow using the 2.1 context
		// DestroyContext();
		m_hRenderContext = tempContext;
		return;
	}

	// If the context creation extension is available, create an Opengl 4.5 context and make it active(replacing the temporary one)
	// If not, keep using the 2.1 context
	if (wgl::exts::var_ARB_create_context)
	{
		int attributes[] = {
			wgl::CONTEXT_MAJOR_VERSION_ARB, 4,
			wgl::CONTEXT_MINOR_VERSION_ARB, 5,
			wgl::CONTEXT_FLAGS_ARB, wgl::CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
			0
		};

		m_hRenderContext = wgl::CreateContextAttribsARB(m_hDeviceContext, nullptr, attributes);

		wglDeleteContext(tempContext);
		wglMakeCurrent(m_hDeviceContext, m_hRenderContext);
	}
	else
	{
		// TODO: Decide if crash or allow using the 2.1 context
		// DestroyContext();
		m_hRenderContext = tempContext;
	}

}
Beispiel #10
0
//---------------------------------------------------------------------------//
// Init
//
//---------------------------------------------------------------------------//
bool CFilterDll::Init(COptions &aOptions)
{
  m_Ok = false;

  const string &sFile = aOptions.Option("library");
  if (sFile == "")
  {
    GLOG(("ERR: Library file not specified\n"));
    return false;
  }
  m_hLibrary = LoadLibrary(sFile.c_str());
  if (!m_hLibrary)
  {
    GLOG(("ERR: Can't load library %s\n", sFile.c_str()));
    return false;
  }

  if (!LoadFunctions())
  {
    GLOG(("ERR: FilterDLL version from file %s is not compatible with current version (%d)\n", sFile.c_str(), FILTER_VERSION));
    FreeLibrary(m_hLibrary);
    return false;
  }

  // Filter init
  int iErr = m_pFncInit(FILTER_VERSION, this, g_DisplayDevice.GetD3DDevice(), aOptions.Options(), &m_uID);
  if (iErr)
  {
    if (iErr == -1)
      GLOG(("ERR: FilterDLL version from file %s is not compatible with this one (%d)\n", sFile.c_str(), FILTER_VERSION));
    else
      GLOG(("ERR: FilterDLL can't load library %s. Return code = %d\n", sFile.c_str(), iErr));
    FreeLibrary(m_hLibrary);
    return false;
  }

  m_Ok = true;
  return m_Ok;
}
Beispiel #11
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_LibHandle != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
    if (m_LibHandle == NULL)
    {
        return false;
    }

    // Get DLL information
    void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    LoadFunction(CloseDLL);
    LoadFunction(RomOpen);
    LoadFunction(RomClosed);
    _LoadFunction("PluginLoaded", PluginOpened);
    LoadFunction(DllConfig);
    LoadFunction(DllAbout);

    LoadFunction(SetSettingInfo3);
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    LoadFunction(SetSettingInfo2);
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    LoadFunction(SetSettingInfo);
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
    {
        return false;
    }

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}
Beispiel #12
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_hDll != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    if (bHaveDebugger())
    {
        m_hDll = LoadLibrary(FileName);
    }
    else
    {
        UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
        m_hDll = LoadLibrary(FileName);
        SetErrorMode(LastErrorMode);
    }

    if (m_hDll == NULL)
    {
        return false;
    }

    // Get DLL information
    void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    CloseDLL = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "CloseDLL");
    RomOpen = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomOpen");
    RomClosed = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomClosed");
    PluginOpened = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "PluginLoaded");
    DllConfig = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllConfig");
    DllAbout = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllAbout");

    SetSettingInfo3 = (void(__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo3");
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    SetSettingInfo2 = (void(__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo2");
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    SetSettingInfo = (void(__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo");
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
        return false;

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}