Exemplo n.º 1
0
void ACTIVE_TASK::init_app_init_data(APP_INIT_DATA& aid) {
    PROJECT* project = wup->project;
    aid.major_version = BOINC_MAJOR_VERSION;
    aid.minor_version = BOINC_MINOR_VERSION;
    aid.release = BOINC_RELEASE;
    aid.app_version = app_version->version_num;
    safe_strcpy(aid.app_name, wup->app->name);
    safe_strcpy(aid.symstore, project->symstore);
    safe_strcpy(aid.acct_mgr_url, gstate.acct_mgr_info.master_url);
    if (project->project_specific_prefs.length()) {
        aid.project_preferences = strdup(
            project->project_specific_prefs.c_str()
        );
    }
    aid.userid = project->userid;
    aid.teamid = project->teamid;
    aid.hostid = project->hostid;
    safe_strcpy(aid.user_name, project->user_name);
    safe_strcpy(aid.team_name, project->team_name);
    safe_strcpy(aid.project_dir, project->project_dir_absolute());
    relative_to_absolute("", aid.boinc_dir);
    safe_strcpy(aid.authenticator, project->authenticator);
    aid.slot = slot;
#ifdef _WIN32
    if (strstr(gstate.host_info.os_name, "Windows 2000")) {
        // Win2K immediately reuses PIDs, so can't use this mechanism
        //
        aid.client_pid = 0;
    } else {
        aid.client_pid = GetCurrentProcessId();
    }
#else
    aid.client_pid = getpid();
#endif
    safe_strcpy(aid.wu_name, wup->name);
    safe_strcpy(aid.result_name, result->name);
    aid.user_total_credit = project->user_total_credit;
    aid.user_expavg_credit = project->user_expavg_credit;
    aid.host_total_credit = project->host_total_credit;
    aid.host_expavg_credit = project->host_expavg_credit;
    double rrs = gstate.runnable_resource_share(RSC_TYPE_CPU);
    if (rrs) {
        aid.resource_share_fraction = project->resource_share/rrs;
    } else {
        aid.resource_share_fraction = 1;
    }
    aid.host_info = gstate.host_info;
    aid.proxy_info = working_proxy_info;
    aid.global_prefs = gstate.global_prefs;
    aid.starting_elapsed_time = checkpoint_elapsed_time;
    aid.using_sandbox = g_use_sandbox;
    aid.vm_extensions_disabled = gstate.host_info.p_vm_extensions_disabled;
    aid.rsc_fpops_est = wup->rsc_fpops_est;
    aid.rsc_fpops_bound = wup->rsc_fpops_bound;
    aid.rsc_memory_bound = wup->rsc_memory_bound;
    aid.rsc_disk_bound = wup->rsc_disk_bound;
    aid.computation_deadline = result->computation_deadline();
    int rt = app_version->gpu_usage.rsc_type;
    if (rt) {
        COPROC& cp = coprocs.coprocs[rt];
        if (coproc_type_name_to_num(cp.type) >= 0) {
            // Standardized vendor name ("NVIDIA", "ATI" or "intel_gpu")
            safe_strcpy(aid.gpu_type, cp.type);
        } else {
            // For other vendors, use vendor name as returned by OpenCL
            safe_strcpy(aid.gpu_type, cp.opencl_prop.vendor);
        }
        int k = result->coproc_indices[0];
        if (k<0 || k>=cp.count) {
            msg_printf(0, MSG_INTERNAL_ERROR,
                "init_app_init_data(): coproc index %d out of range", k
            );
            k = 0;
        }
        aid.gpu_device_num = cp.device_nums[k];
        aid.gpu_opencl_dev_index = cp.opencl_device_indexes[k];
        aid.gpu_usage = app_version->gpu_usage.usage;
    } else {
        strcpy(aid.gpu_type, "");
        aid.gpu_device_num = -1;
        aid.gpu_opencl_dev_index = -1;
        aid.gpu_usage = 0;
    }
    aid.ncpus = app_version->avg_ncpus;
    aid.vbox_window = cc_config.vbox_window;
    aid.checkpoint_period = gstate.global_prefs.disk_interval;
    aid.fraction_done_start = 0;
    aid.fraction_done_end = 1;
#ifdef _WIN32
    safe_strcpy(aid.shmem_seg_name, shmem_seg_name);
#else
    aid.shmem_seg_name = shmem_seg_name;
#endif
    aid.wu_cpu_time = checkpoint_cpu_time;
    APP_VERSION* avp = app_version;
    for (unsigned int i=0; i<avp->app_files.size(); i++) {
        FILE_REF& fref = avp->app_files[i];
        aid.app_files.push_back(string(fref.file_name));
    }
}