// returns
// - 0 if success
// - ERR_FOPEN if init_data.xml missing
// - ERR_XML_PARSE if can't parse init_data.xml
// - ERR_NOT_FOUND if missing <gpu_type> or <gpu_device_num> fields
// - an OpenCL error number if OpenCL error
//
int boinc_get_opencl_ids(cl_device_id* device, cl_platform_id* platform) {
    int retval;
    APP_INIT_DATA aid;
    int opencl_device_index;

    retval = boinc_parse_init_data_file();
    if (retval) return retval;
    boinc_get_init_data(aid);

    if (!strlen(aid.gpu_type)) {
        fprintf(stderr, "GPU type not found in %s\n", INIT_DATA_FILE);
        return ERR_NOT_FOUND;
    }

    opencl_device_index = aid.gpu_opencl_dev_index;
    if (opencl_device_index < 0) {
        // Older versions of init_data.xml don't have gpu_opencl_dev_index field
        opencl_device_index = aid.gpu_device_num;
    }

    if (opencl_device_index < 0) {
        fprintf(stderr, "GPU device # not found in %s\n", INIT_DATA_FILE);
        return ERR_NOT_FOUND;
    }

    retval = boinc_get_opencl_ids_aux(
                 aid.gpu_type, opencl_device_index, device, platform
             );

    return retval;
}
示例#2
0
int main(int argc, char** argv) {
#if (defined(__APPLE__) && defined(_DEBUG))
    // Provide a way to get error messages from system in Debug builds only. 
    // In Deployment builds, ownership violates sandbox security (unless we 
    // gave it an explicit path outside the BOINC Data directory). 
    freopen("gfx_stderr.txt", "w", stderr);
#endif
    boinc_parse_init_data_file();
    boinc_get_init_data(sah_aid);
    if (sah_aid.project_preferences) {
        sah_graphics.parse_project_prefs(sah_aid.project_preferences);
    }
    boinc_graphics_loop(argc, argv);
}
示例#3
0
// Deprecated: use the version above instead
//
// returns
// - 0 if success
// - ERR_FOPEN if init_data.xml missing
// - ERR_XML_PARSE if can't parse init_data.xml
// - ERR_NOT_FOUND if missing <gpu_type> or <gpu_device_num> fields
// - an OpenCL error number if OpenCL error
//
int boinc_get_opencl_ids(cl_device_id* device, cl_platform_id* platform) {
    int retval;
    APP_INIT_DATA aid;

    retval = boinc_parse_init_data_file();
    if (retval) return retval;
    boinc_get_init_data(aid);
    
    if (!strlen(aid.gpu_type)) {
        fprintf(stderr, "GPU type not found in %s\n", INIT_DATA_FILE);
        return ERR_NOT_FOUND;
    }
    
    if ((aid.gpu_opencl_dev_index < 0) && (aid.gpu_device_num < 0)) {
        fprintf(stderr, "GPU device # not found in %s\n", INIT_DATA_FILE);
        return ERR_NOT_FOUND;
    }

    retval = boinc_get_opencl_ids_aux(
        aid.gpu_type, aid.gpu_opencl_dev_index, aid.gpu_device_num, device, platform
    );

    return retval;
}
示例#4
0
// This version is compatible with older clients.
// Usage:
// Pass the argc and argv received from the BOINC client
// type: may be PROC_TYPE_NVIDIA_GPU, PROC_TYPE_AMD_GPU or PROC_TYPE_INTEL_GPU
//       (it may also be 0, but then it will fail on older clients.)
//
// The argc, argv and type arguments are ignored for 7.0.12 or later clients.
//
// returns
// - 0 if success
// - ERR_FOPEN if init_data.xml missing
// - ERR_XML_PARSE if can't parse init_data.xml
// - CL_INVALID_DEVICE_TYPE if unable to get gpu_type information
// - ERR_NOT_FOUND if unable to get opencl_device_index or gpu device_num
// - an OpenCL error number if OpenCL error
//
int boinc_get_opencl_ids(
    int argc, char** argv, int type,
    cl_device_id* device, cl_platform_id* platform
){
    int retval;
    APP_INIT_DATA aid;
    char *gpu_type = NULL;
    int gpu_device_num = -1;
    int i;

    retval = boinc_parse_init_data_file();
    if (retval) return retval;
    boinc_get_init_data(aid);
    
    if (strlen(aid.gpu_type)) {
        gpu_type = aid.gpu_type;
    } else {
        switch (type) {
        case PROC_TYPE_NVIDIA_GPU:
            gpu_type = (char *)GPU_TYPE_NVIDIA;
            break;
        case PROC_TYPE_AMD_GPU:
            gpu_type = (char *)GPU_TYPE_ATI;
            break;
        case PROC_TYPE_INTEL_GPU:
            gpu_type = (char *)GPU_TYPE_INTEL;
            break;
        }
    }
    
    if ((!gpu_type) || !strlen(gpu_type)) {
        fprintf(stderr, "GPU type not found in %s\n", INIT_DATA_FILE);
        return CL_INVALID_DEVICE_TYPE;
    }
    
    if (aid.gpu_opencl_dev_index < 0) {
        // Older versions of init_data.xml don't have gpu_opencl_dev_index field
        //
        gpu_device_num = aid.gpu_device_num;
        if (gpu_device_num < 0) {
            // Even older versions of init_data.xml don't have gpu_device_num field
            for (i=0; i<argc-1; i++) {
                if ((!strcmp(argv[i], "--device")) || (!strcmp(argv[i], "-device"))) {
                    gpu_device_num = atoi(argv[i+1]);
                    break;
                }
            }
        }
    }

    if ((aid.gpu_opencl_dev_index < 0) && (gpu_device_num < 0)) {
        fprintf(stderr, "GPU device # not found in %s\n", INIT_DATA_FILE);
        return ERR_NOT_FOUND;
    }

    retval = boinc_get_opencl_ids_aux(
        gpu_type, aid.gpu_opencl_dev_index, gpu_device_num, device, platform
    );

    return retval;
}
示例#5
0
HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
{
    HRESULT hr = 0;
    RECT rc = {0, 0, 0, 0};
    DWORD dwExStyle = 0;
    DWORD dwStyle = 0;
    char szWindowTitle[256];
    char szWindowInfo[256];
    char szDebuggingInfo[256];
    int iWebServerPort = 0;
    char szWebServerUsername[256];
    char szWebServerPassword[256];


	hr = __super::PreMessageLoop(nShowCmd);
	if (FAILED(hr)) {
        return hr;
	}

    // Initialize ATL Window Classes
    //
    AtlAxWinInit();

    // Prepare environment for web browser control
    //
    RegisterWebControlCompatiblity();

    // Prepare environment for detecting system conditions
    //
    boinc_parse_init_data_file();

    // Initialize Web Server
    //
    _snprintf(szWebServerUsername, sizeof(szWebServerUsername)-1, "%d", GetCurrentThreadId());
    _snprintf(szWebServerPassword, sizeof(szWebServerPassword)-1, "%d", GetCurrentThreadId());
    boinc_get_port(false, iWebServerPort);
    webserver_initialize(iWebServerPort, szWebServerUsername, szWebServerPassword, m_bDebugging);
        
    // Create Window Instance
    //
    m_pWnd = new CHTMLBrowserWnd();
	if (m_pWnd == NULL)
	{
		__super::PostMessageLoop();
		return E_OUTOFMEMORY;
	}

    // Store a copy of APP_INIT_DATA for future use
    //
    boinc_get_init_data(m_pWnd->aid);

    // Store web server information for future use
    //
    m_pWnd->m_iWebServerPort = iWebServerPort;
    m_pWnd->m_strWebServerUsername = szWebServerUsername;
    m_pWnd->m_strWebServerPassword = szWebServerPassword;

    // Construct the window caption
    //
    if (m_pWnd->aid.app_version) {
        snprintf(
            szWindowInfo, sizeof(szWindowInfo),
            "%s version %.2f [workunit: %s]",
            m_pWnd->aid.app_name, m_pWnd->aid.app_version/100.0, m_pWnd->aid.wu_name
        );
    } else {
        snprintf(
            szWindowInfo, sizeof(szWindowInfo),
            "%s [workunit: %s]",
            m_pWnd->aid.app_name, m_pWnd->aid.wu_name
        );
    }

    if (m_bDebugging) {
        snprintf(szDebuggingInfo, sizeof(szDebuggingInfo), "[Web Server Port: %d]", iWebServerPort);
    } else {
        strcpy(szDebuggingInfo, "");
    }

    snprintf(szWindowTitle, sizeof(szWindowTitle)-1, "%s %s", szWindowInfo, szDebuggingInfo);

    // Determine window size and placement
    if (m_bFullscreen) {
        HDC dc = GetDC(NULL);
        rc.left = 0;
        rc.top = 0;
        rc.right = GetDeviceCaps(dc, HORZRES);
        rc.bottom = GetDeviceCaps(dc, VERTRES);
        ReleaseDC(NULL, dc);

        dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_POPUP;
        dwExStyle = WS_EX_APPWINDOW|WS_EX_TOPMOST;
        while(ShowCursor(false) >= 0);
    } else {
        rc.left = 0;
        rc.top = 0;
        rc.right = 1024;
        rc.bottom = 768;

        dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW;
        dwExStyle = WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        while(ShowCursor(true) < 0);
    }

    // Create Window
    //
	m_pWnd->Create(GetDesktopWindow(), rc, szWindowTitle, dwStyle, dwExStyle);
	m_pWnd->ShowWindow(nShowCmd);

	return S_OK;
}
示例#6
0
int main(int argc, char** argv) {
  int retval = 0, i;
  FORCE_FRAME_POINTER;
  run_stage=PREGRX;
  g_argc=argc;

  if (!(g_argv=(char **)calloc(argc+2,sizeof(char *)))) {
    exit(MALLOC_FAILED);
  }


  setbuf(stdout, 0);

  bool standalone = false;
  g_argv[0]=argv[0];

  for (i=1; i<argc; i++) {
    g_argv[i]=argv[i];
    char *p=argv[i];
    while (*p=='-') p++;
    if (!strncmp(p,"vers",4)) {
      print_version();
      exit(0);
    } else if (!strncmp(p,"verb",4)) {
      verbose = true;
    } else if (!strncmp(p, "st", 2)) {
        standalone = true;
#ifdef BOINC_APP_GRAPHICS
        nographics_flag = true;
#endif
    } else if (!strncmp(p, "nog", 3)) {
#ifdef BOINC_APP_GRAPHICS
        nographics_flag = true;
#endif
    } else if (!strncmp(p, "not", 3)) {
        notranspose_flag = true;
    } else if (!strncmp(p, "def", 3)) {
        default_functions_flag = true;
    } else {
      fprintf(stderr, "bad arg: %s\n", argv[i]);
      usage();
      exit(1);
    }
  }

  try {

    // Initialize Diagnostics
    //
    unsigned long dwDiagnosticsFlags = 0;

    dwDiagnosticsFlags = 
        BOINC_DIAG_DUMPCALLSTACKENABLED | 
        BOINC_DIAG_HEAPCHECKENABLED |
        BOINC_DIAG_TRACETOSTDERR |
        BOINC_DIAG_REDIRECTSTDERR;

    retval = boinc_init_diagnostics(dwDiagnosticsFlags);
    if (retval) {
      SETIERROR(retval, "from boinc_init_diagnostics()");
    }

#ifdef __APPLE__
    setMacIcon(argv[0], MacAppIconData, sizeof(MacAppIconData));
#ifdef __i386__
    rlimit rlp;
    
    getrlimit(RLIMIT_STACK, &rlp);
    rlp.rlim_cur = rlp.rlim_max;
    setrlimit(RLIMIT_STACK, &rlp);
#endif
#endif

    // Initialize BOINC
    //

    boinc_parse_init_data_file();
    boinc_get_init_data(app_init_data);
#ifdef BOINC_APP_GRAPHICS
    sah_graphics_init(app_init_data);
#endif
    retval = boinc_init();
    if (retval) {
      SETIERROR(retval, "from boinc_init()");
    }
    worker();
  }
  catch (seti_error e) {
    e.print();
    exit(static_cast<int>(e));
  }
  return 0;
}
示例#7
0
void boinc_parse_init_data_file_() {
    boinc_parse_init_data_file();
}