コード例 #1
0
void handle_request(FILE* fin, FILE* fout, char* code_sign_key) {
    SCHEDULER_REQUEST sreq;
    SCHEDULER_REPLY sreply;
    char buf[1024];

    g_request = &sreq;
    g_reply = &sreply;
    g_wreq = &sreply.wreq;

    sreply.nucleus_only = true;

    log_messages.set_indent_level(1);

    MIOFILE mf;
    XML_PARSER xp(&mf);
    mf.init_file(fin);
    const char* p = sreq.parse(xp);
    double start_time = dtime();
    if (!p){
        process_request(code_sign_key);

        if ((config.locality_scheduling || config.locality_scheduler_fraction) && !sreply.nucleus_only) {
            send_file_deletes();
        }
    } else {
        sprintf(buf, "Error in request message: %s", p);
        log_incomplete_request();
        sreply.insert_message(buf, "low");
    }

    if (config.debug_user_messages) {
        log_user_messages();
    }

    sreply.write(fout, sreq);
    log_messages.printf(MSG_NORMAL,
        "Scheduler ran %.3f seconds\n", dtime()-start_time
    );

    if (strlen(config.sched_lockfile_dir)) {
        unlock_sched();
    }
}
コード例 #2
0
ファイル: collectd-tg.c プロジェクト: beorn-/collectd
static lcc_value_list_t *create_value_list (void) /* {{{ */
{
  lcc_value_list_t *vl;
  int host_num;

  vl = calloc (1, sizeof (*vl));
  if (vl == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    return (NULL);
  }

  vl->values = calloc (/* nmemb = */ 1, sizeof (*vl->values));
  if (vl->values == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    free (vl);
    return (NULL);
  }

  vl->values_types = calloc (/* nmemb = */ 1, sizeof (*vl->values_types));
  if (vl->values_types == NULL)
  {
    fprintf (stderr, "calloc failed.\n");
    free (vl->values);
    free (vl);
    return (NULL);
  }

  vl->values_len = 1;

  host_num = get_boundet_random (0, conf_num_hosts);

  vl->interval = conf_interval;
  vl->time = 1.0 + dtime ()
    + (host_num % (1 + (int) vl->interval));

  if (get_boundet_random (0, 2) == 0)
    vl->values_types[0] = LCC_TYPE_GAUGE;
  else
    vl->values_types[0] = LCC_TYPE_DERIVE;

  snprintf (vl->identifier.host, sizeof (vl->identifier.host),
      "host%04i", host_num);
  snprintf (vl->identifier.plugin, sizeof (vl->identifier.plugin),
      "plugin%03i", get_boundet_random (0, conf_num_plugins));
  strncpy (vl->identifier.type,
      (vl->values_types[0] == LCC_TYPE_GAUGE) ? "gauge" : "derive",
      sizeof (vl->identifier.type));
  vl->identifier.type[sizeof (vl->identifier.type) - 1] = 0;
  snprintf (vl->identifier.type_instance, sizeof (vl->identifier.type_instance),
      "ti%li", random ());

  return (vl);
} /* }}} int create_value_list */
コード例 #3
0
ファイル: main.cpp プロジェクト: hirokiu/csn_raspi
// add your sensor class below, i.e. CSensorTest
int main(int argc, char** argv)
{
    const float RUN_SECONDS = 100.0f; // how many seconds to run -- max is 200 seconds (or bump up MAXI in define.h to RUN_SECONDS / DT )

    int iRetVal = 0, iErrCnt = 0;
    sm = new CQCNShMem();

    CSensorLinuxUSBONavi sms;

    if (sms.detect()) {
       double tstart = dtime(), tend;
       // initialize timers
       sm->t0active = tstart; // use the function in boinc/lib
       sm->t0check = sm->t0active + sm->dt;

       // MySQL
       sms.connectDatabase();

       // assuming we're at 50Hz, run 500 times for 10 seconds of output, note array only holds 10,000 so don't go past that!
			 //sm->lOffset++;	//debug
       //for (sm->lOffset = 0; sm->lOffset < (int) (RUN_SECONDS / DT); sm->lOffset++) {	//debug
       while(true){
           if (!sms.mean_xyz(true)) iErrCnt++;   // pass in true for verbose output, false for silent
       }

       tend = dtime();
       fprintf(stdout, "%f seconds of samples read from %f to %f in %f seconds real time -- error of %3.3f %c\n"
               "%d Timing Errors Encountered\n",
	  RUN_SECONDS, tstart, tend, tend - tstart, ((RUN_SECONDS - (tend - tstart)) / RUN_SECONDS) * 100.0f, '%', iErrCnt);
    }
    else {
       fprintf(stdout, "No sensor detected!\n");
       iRetVal = 1;
    }

    if (sm) {
        delete sm;
        sm = NULL;
    }

    return iRetVal;
}
コード例 #4
0
ファイル: test.cpp プロジェクト: troore/unico
void test_equalizer_chain_pth(LTE_PHY_PARAMS *lte_phy_params)
{
	double tstart, tend, ttime;
	
	GeneRandomInput((lte_phy_params + 0)->ofdemod_in, (lte_phy_params + 0)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");
	GeneRandomInput((lte_phy_params + 1)->ofdemod_in, (lte_phy_params + 1)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");
	GeneRandomInput((lte_phy_params + 2)->ofdemod_in, (lte_phy_params + 2)->ofdemod_in_buf_sz, "./testsuite/SubCarrierMapInputReal", "./testsuite/SubCarrierMapInputImag");

	tstart = dtime();
	
	equalizer_chain_pth(lte_phy_params);

	tend = dtime();
	ttime = tend - tstart;
	printf("%.3fms\n", ttime);

	WriteOutputToFiles((lte_phy_params + 0)->eq_out, (lte_phy_params + 0)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
	WriteOutputToFiles((lte_phy_params + 1)->eq_out, (lte_phy_params + 1)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
	WriteOutputToFiles((lte_phy_params + 2)->eq_out, (lte_phy_params + 2)->eq_out_buf_sz, "./testsuite/testLSCELSEqOutputReal", "./testsuite/testLSCELSEqOutputImag");
}
コード例 #5
0
ファイル: windows_opengl.cpp プロジェクト: drshawnkwang/boinc
static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) {
    RECT rt;
    int width, height;
    char buf[MSG_CHANNEL_SIZE];
	if (g_sleep) return;

    // check for graphics-related message from core client
    //
    if (app_client_shm) {
        if (app_client_shm->shm->graphics_request.get_msg(buf)) {
            BOINCINFO("Received Graphics Message: %s", buf);
            app_client_shm->decode_graphics_msg(buf, graphics_msg);
            switch (graphics_msg.mode) {
            case MODE_REREAD_PREFS:
                // only reread graphics prefs if we have a window open
                //
                switch(current_graphics_mode) {
                case MODE_WINDOW:
                case MODE_FULLSCREEN:
                    app_graphics_reread_prefs();
                    break;
                }
                break;
            case MODE_HIDE_GRAPHICS:
            case MODE_WINDOW:
            case MODE_FULLSCREEN:
            case MODE_BLANKSCREEN:
                set_mode(graphics_msg.mode);
                break;
            }
        }
        // ack graphics mode
        //
        if (acked_graphics_mode != current_graphics_mode) {
            bool sent = app_client_shm->shm->graphics_reply.send_msg(
                xml_graphics_modes[current_graphics_mode]
            );
            if (sent) acked_graphics_mode = current_graphics_mode;
        }
    }
    if (!visible) return;
    if (current_graphics_mode == MODE_HIDE_GRAPHICS) return;
    if (!hWnd) return;

    // TODO: remove width, height from API
    //
    GetClientRect(hWnd, &rt);
    width = rt.right-rt.left;
    height = rt.bottom-rt.top;

    if (throttled_app_render(width, height, dtime())) {
        SwapBuffers(hDC);
    }
}
コード例 #6
0
ファイル: write.c プロジェクト: amcinnes/uc_am_xmit
void callback(struct libusb_transfer *xfr) {
	if (xfr->status!=LIBUSB_TRANSFER_COMPLETED) {
		fprintf(stderr,"Transfer failed: %d\n",xfr->status);
		exit(1);
	}
	transfer(xfr);

	total += xfr->length;
	double rate = total/(dtime()-t);
	fprintf(stderr,"%10d %lf\n",total,rate);
}
コード例 #7
0
ファイル: bucketsort.c プロジェクト: dankogai/c-bucketsort
int bucketsort(void **a, size_t n, keyaccessor_t key, indexer_t idx,
	       comparator_t cmp)
{
    _cons_t *lists = (_cons_t *) malloc(n * sizeof(_cons_t));
    if (!lists) {
	perror("malloc failed!");
	return -1;
    }
    #if BUCKETSORT_PROFILE
    when = dtime(); array2list(a, lists, n); ptime();
    when = dtime(); list_t l = bucketsort_l(lists, key, idx, cmp); ptime();
    when = dtime(); list2array(l, a, n); ptime();
    #else
    array2list(a, lists, n);
    list_t l = bucketsort_l(lists, key, idx, cmp);
    list2array(l, a, n);
    #endif
    free(lists);
    return 0;
}
コード例 #8
0
ファイル: sandbox.C プロジェクト: phenix3443/synecdoche
/// Delete the file located at path.
/// If "retry" is set, do retries for 5 sec in case some
/// other program (e.g. virus checker) has the file locked.
/// Don't do this if deleting directories - it can lock up the Manager.
///
/// \param[in] path The path name of the file that should be deleted.
/// \param[in] retry If true this function will try to delete the file
///                  multiple times if the first attempt failed.
/// \return Zero on success, ERR_UNLINK on error.
int delete_project_owned_file(const char* path, bool retry) {
    int retval = 0;

    if (!boinc_file_or_symlink_exists(path)) {
        return 0;
    }
    retval = delete_project_owned_file_aux(path);
    if (retval && retry) {
        double start = dtime();
        do {
            boinc_sleep(drand() * 2.0);       // avoid lockstep
            retval = delete_project_owned_file_aux(path);
            if (!retval) break;
        } while (dtime() < start + FILE_RETRY_INTERVAL);
    }
    if (retval) {
        safe_strcpy(boinc_failed_file, path);
        return ERR_UNLINK;
    }
    return 0;
}
コード例 #9
0
int RPC_CLIENT::init_poll() {
    fd_set read_fds, write_fds, error_fds;
    struct timeval tv;
    int retval;

    FD_ZERO(&read_fds);
    FD_ZERO(&write_fds);
    FD_ZERO(&error_fds);

    FD_SET(sock, &read_fds);
    FD_SET(sock, &write_fds);
    FD_SET(sock, &error_fds);

    BOINCTRACE("RPC_CLIENT::init_poll sock = %d\n", sock);

    tv.tv_sec = tv.tv_usec = 0;
    select(FD_SETSIZE, &read_fds, &write_fds, &error_fds, &tv);
    retval = 0;
    if (FD_ISSET(sock, &error_fds)) {
        retval =  ERR_CONNECT;
    } else if (FD_ISSET(sock, &write_fds)) {
        retval = get_socket_error(sock);
        if (!retval) {
            BOINCTRACE("RPC_CLIENT::init_poll connected to port %d\n", ntohs(addr.sin_port));
            retval = boinc_socket_asynch(sock, false);
            if (retval) {
                BOINCTRACE("asynch error: %d\n", retval);
                return retval;
            }
            return 0;
        } else {
            BOINCTRACE("init_poll: get_socket_error(): %d\n", retval);
        }
    }
    if (dtime() > start_time + timeout) {
        BOINCTRACE("RPC_CLIENT init timed out\n");
        return ERR_CONNECT;
    }
    if (retval) {
        if (retry) {
            boinc_close_socket(sock);
            retval = boinc_socket(sock);
            retval = boinc_socket_asynch(sock, true);
            retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr));
            BOINCTRACE("RPC_CLIENT::init_poll attempting connect\n");
            return ERR_RETRY;
        } else {
            return ERR_CONNECT;
        }
    }
    return ERR_RETRY;
}
コード例 #10
0
ファイル: work_generator.cpp プロジェクト: godlytalias/BOINC
void main_loop() {
    int retval;
    int node=0,n;
    while (node<n1) {
        check_stop_daemons();
	retval = count_unsent_results(n, 0);
        if (retval) {
            log_messages.printf(MSG_CRITICAL,
                "count_unsent_jobs() failed: %s\n", boincerror(retval)
            );
            exit(retval);
        }
        if (n > CUSHION) {
            daemon_sleep(5);
        } else {

          //  int njobs =  (CUSHION-n)/REPLICATION_FACTOR;
            log_messages.printf(MSG_DEBUG,
                "Making job for %d\n", node
            );
      //      for (int i=0; i<njobs; i++) {
      	      for (int i=0; i<n1; i+=CLIENT_LIMIT)
      	      {
                retval = make_job(node,i);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "can't make job: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
      	      }
   //         }
            // Now sleep for a few seconds to let the transitioner
            // create instances for the jobs we just created.
            // Otherwise we could end up creating an excess of jobs.
            double now = dtime();
            while (1) {
                daemon_sleep(5);
                double x;
                retval = min_transition_time(x);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "min_transition_time failed: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
                if (x > now) break;
            }
        }
        node++;
    }
}
コード例 #11
0
ファイル: test.cpp プロジェクト: troore/ParWiBench
void tx_rate_matching(LTE_PHY_PARAMS *lte_phy_params)
{
	std::cout << "Tx RateMatching starts" << std::endl;

	//ReadInputFromFiles(lte_phy_params->rm_in, lte_phy_params->rm_in_buf_sz, "../testsuite/RandomTxRateMatchInput");
	GeneRandomInput(lte_phy_params->rm_in, lte_phy_params->rm_in_buf_sz, "/root/RateMatching/testsuite/RandomTxRateMatchInput");
	TxRateMatching(lte_phy_params, lte_phy_params->rm_in, lte_phy_params->rm_out);
	double energy,ttime,tbegin;
	micpower_start();
	tbegin = dtime();
	for(int i=0;i<10000;i++)
		TxRateMatching(lte_phy_params, lte_phy_params->rm_in, lte_phy_params->rm_out);
	ttime = dtime() - tbegin;
	energy = micpower_finalize();
//	printf("Energy used in %lf\n", energy);
//	printf("whole time is %fms\n", ttime);
	printf("%lf\t%f\t%f\n", energy, ttime, (energy * 1000.0) / ttime);
	
	WriteOutputToFiles(lte_phy_params->rm_out, lte_phy_params->rm_out_buf_sz, "/root/RateMatching/testsuite/testTxRateMatchOutput");

	std::cout << "Tx RateMatching ends" << std::endl;
}
コード例 #12
0
ファイル: test.cpp プロジェクト: troore/ParWiBench
void test_turbo_decoding(LTE_PHY_PARAMS *lte_phy_params, int n_log_decoder_iters)
{
	std::cout << "Turbo Decoder starts" << std::endl;
	
	ReadInputFromFiles(lte_phy_params->td_in, lte_phy_params->td_in_buf_sz, "../testsuite/testTurboEncoderOutput");
	
	for (int i = 0; i < lte_phy_params->td_in_buf_sz; i++)
	{
		lte_phy_params->td_in[i] = (1 - 2 * lte_phy_params->td_in[i]);
	}

	double tstart, tend, ttime;
	double n_gflops, gflops;

	tstart = dtime();

	int n_test_iters = 1;
	for (int i = 0; i < n_test_iters; i++)
	{
	turbo_decoding(lte_phy_params, lte_phy_params->td_in, lte_phy_params->td_out, n_log_decoder_iters);
	}

	tend = dtime();
	ttime = tend - tstart;
	n_gflops = n_test_iters * gflop_counter(lte_phy_params);
	gflops = (n_gflops * 10e3) / ttime;
//	printf("%fms\n", ttime);
//	printf("Number of gflops = %lf\n", n_gflops);
//	printf("GFlops = %f\n", gflops);

	for (int i = 0; i < lte_phy_params->td_out_buf_sz; i++)
	{
		lte_phy_params->td_out[i] = (1 - lte_phy_params->td_out[i]) / 2;
	}
	
	WriteOutputToFiles(lte_phy_params->td_out, lte_phy_params->td_out_buf_sz, "../testsuite/testTurboDecoderOutput");
	
	std::cout << "Turbo Decoder ends" << std::endl;
}
コード例 #13
0
ファイル: sched_types.cpp プロジェクト: freehal/boinc-freehal
void GLOBAL_PREFS::parse(const char* buf, const char* venue) {
    char buf2[BLOB_SIZE];
    double dtemp;

    defaults();

    if (parse_double(buf, "<mod_time>", mod_time)) {
        // mod_time is outside of venue
        if (mod_time > dtime()) mod_time = dtime();
    }
    extract_venue(buf, venue, buf2);
    parse_double(buf2, "<disk_max_used_gb>", disk_max_used_gb);
    parse_double(buf2, "<disk_max_used_pct>", disk_max_used_pct);
    parse_double(buf2, "<disk_min_free_gb>", disk_min_free_gb);
    parse_double(buf2, "<work_buf_min_days>", work_buf_min_days);
    if (parse_double(buf2, "<ram_max_used_busy_pct>", dtemp)) {
        ram_max_used_busy_frac = dtemp/100.;
    }
    if (parse_double(buf2, "<ram_max_used_idle_pct>", dtemp)) {
        ram_max_used_idle_frac = dtemp/100.;
    }
    parse_double(buf2, "<max_ncpus_pct>", max_ncpus_pct);
}
コード例 #14
0
ファイル: brainstorm.c プロジェクト: bsummer4/midiutils
void writefile () {
	if (!activevents) errx(1,"Internal error");
	E("write", write(1, header, sizeof(header)));
	struct timeval lastime = events[0].time;
	int remain = activevents;
	for (ME* cur = events; remain; remain--, cur++) {
		write_variable_length_quantity(dtime(lastime, cur->time));
		lastime = cur->time;
		mm_write(1, &cur->m); }
	E("write", write(1, trailer, sizeof(trailer)));
	off_t ending_offset;
 	E("lseek", (ending_offset = lseek(1, 0, SEEK_CUR)));
	E("lseek", lseek(1, 18, SEEK_SET));
	write_four_byte_int(ending_offset - sizeof(header), 1); }
コード例 #15
0
void main_loop() {
    int retval;

    while (1) {
        check_stop_daemons();
        long n;
        retval = count_unsent_results(n, app.id);
        if (retval) {
            log_messages.printf(MSG_CRITICAL,
                "count_unsent_jobs() failed: %s\n", boincerror(retval)
            );
            exit(retval);
        }
        if (n > CUSHION) {
            daemon_sleep(10);
        } else {
            int njobs = (CUSHION-n)/REPLICATION_FACTOR;
            log_messages.printf(MSG_DEBUG,
                "Making %d jobs\n", njobs
            );
            for (int i=0; i<njobs; i++) {
                retval = make_job();
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "can't make job: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
            }
            // Wait for the transitioner to create instances
            // of the jobs we just created.
            // Otherwise we'll create too many jobs.
            //
            double now = dtime();
            while (1) {
                daemon_sleep(5);
                double x;
                retval = min_transition_time(x);
                if (retval) {
                    log_messages.printf(MSG_CRITICAL,
                        "min_transition_time failed: %s\n", boincerror(retval)
                    );
                    exit(retval);
                }
                if (x > now) break;
            }
        }
    }
}
コード例 #16
0
ファイル: sandbox.cpp プロジェクト: freehal/boinc-freehal
// Delete the file located at path.
// If "retry" is set, do retries for 5 sec in case some
// other program (e.g. virus checker) has the file locked.
// Don't do this if deleting directories - it can lock up the Manager.
//
int delete_project_owned_file(const char* path, bool retry) {
    int retval = 0;

    if (!boinc_file_or_symlink_exists(path)) {
        return 0;
    }
    retval = delete_project_owned_file_aux(path);
    if (retval && retry) {
        double start = dtime();
        do {
            boinc_sleep(drand()*2);       // avoid lockstep
            retval = delete_project_owned_file_aux(path);
            if (!retval) break;
        } while (dtime() < start + FILE_RETRY_INTERVAL);
    }
    if (retval) {
        safe_strcpy(boinc_failed_file, path);
        return ERR_UNLINK;
    }
    if (log_flags.slot_debug) {
        msg_printf(0, MSG_INFO, "[slot] removed file %s", path);
    }
    return 0;
}
コード例 #17
0
ファイル: Nose_Hoover.cpp プロジェクト: paddy3/StarPolymersMD
Nose_Hoover::Nose_Hoover(Box& box, double dt, double temp, double a_q1, double a_q2 )
    : Thermostat(box, dt),
      TargetTemperature(temp)
    , q1(a_q1)
    , q2(a_q2)
    , xi1(0.0)
    , xi2(0.0)
    , nuxi1(0.0)
    , nuxi2(0.0)
    , g1(0.0)
    , g2(0.0) {
    DeltaTHalf = 0.5*dt;
    DeltaT4 = 0.5*DeltaTHalf;
    DeltaT8 = 0.5*DeltaT4;
    update_temp();
    dtime(dt);
    SimBox.calculate_forces();
}
コード例 #18
0
ファイル: DlgItemProperties.cpp プロジェクト: abergstr/BOINC
void CDlgItemProperties::show_rsc(wxString rsc_name, RSC_DESC rsc_desc) {
    if (rsc_desc.no_rsc_pref) {
        addProperty(_("Don't fetch tasks for ") + rsc_name, _("Project preference"));
    }
    if (rsc_desc.no_rsc_ams) {
        addProperty(_("Don't fetch tasks for ") + rsc_name, _("Account manager preference"));
    }
    if (rsc_desc.no_rsc_apps) {
        addProperty(_("Don't fetch tasks for ") + rsc_name, _("Project has no apps for ") + rsc_name);
    }
    if (rsc_desc.no_rsc_config) {
        addProperty(_("Don't fetch tasks for ") + rsc_name, _("Client configuration excludes ") + rsc_name);
    }
    double x = rsc_desc.backoff_time - dtime();
    if (x<0) x = 0;
    addProperty(rsc_name + _(" work fetch deferred for"), FormatTime(x));
    addProperty(rsc_name + _(" work fetch deferral interval"), FormatTime(rsc_desc.backoff_interval));
}
コード例 #19
0
ファイル: sched_check.cpp プロジェクト: AltroCoin/altrocoin
// return the delay bound to use for this job/host.
// Actually, return two: optimistic (lower) and pessimistic (higher).
// If the deadline check with the optimistic bound fails,
// try the pessimistic bound.
// TODO: clean up this mess
//
static void get_delay_bound_range(
    WORKUNIT& wu,
    int res_server_state, int res_priority, double res_report_deadline,
    BEST_APP_VERSION& bav,
    double& opt, double& pess
) {
    if (res_server_state == RESULT_SERVER_STATE_IN_PROGRESS) {
        double now = dtime();
        if (res_report_deadline < now) {
            // if original deadline has passed, return zeros
            // This will skip deadline check.
            opt = pess = 0;
            return;
        }
        opt = res_report_deadline - now;
        pess = wu.delay_bound;
    } else {
        opt = pess = wu.delay_bound;

        // If the workunit needs reliable and is being sent to a reliable host,
        // then shorten the delay bound by the percent specified
        //
        if (config.reliable_on_priority && res_priority >= config.reliable_on_priority && config.reliable_reduced_delay_bound > 0.01
        ) {
            opt = wu.delay_bound*config.reliable_reduced_delay_bound;
            double est_wallclock_duration = estimate_duration(wu, bav);

            // Check to see how reasonable this reduced time is.
            // Increase it to twice the estimated delay bound
            // if all the following apply:
            //
            // 1) Twice the estimate is longer then the reduced delay bound
            // 2) Twice the estimate is less then the original delay bound
            // 3) Twice the estimate is less then the twice the reduced delay bound
            if (est_wallclock_duration*2 > opt
                && est_wallclock_duration*2 < wu.delay_bound
                && est_wallclock_duration*2 < wu.delay_bound*config.reliable_reduced_delay_bound*2
            ) {
                opt = est_wallclock_duration*2;
            }
        }
    }
}
コード例 #20
0
int handle_add(const char* path) {
    char dir[256], filename[256], buf[1024];
    DB_VDA_FILE vf;
    POLICY policy;
    double size;
    int retval;

    retval = file_size(path, size);
    if (retval) {
        fprintf(stderr, "no file %s\n", path);
        return -1;
    }

    strcpy(dir, path);
    char* p = strrchr(dir, '/');
    *p = 0;
    strcpy(filename, p+1);

    // make sure there's a valid policy file in the dir
    //
    sprintf(buf, "%s/boinc_meta.txt", dir);
    retval = policy.parse(buf);
    if (retval) {
        fprintf(stderr, "Can't parse policy file.\n");
        return -1;
    }

    // add a DB record and mark it for update
    //
    vf.create_time = dtime();
    strcpy(vf.dir, dir);
    strcpy(vf.name, filename);
    vf.size = size;
    vf.need_update = 1;
    vf.initialized = 0;
    retval = vf.insert();
    if (retval) {
        fprintf(stderr, "Can't insert DB record\n");
        return -1;
    }
    return 0;
}
コード例 #21
0
ファイル: graphics2_win.cpp プロジェクト: AltroCoin/altrocoin
static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) {
    RECT rt;
    int width, height;
    static int size_changed = 0;

    GetWindowRect(window, &rt);
    width = rt.right-rt.left;
    height = rt.bottom-rt.top;

    if (throttled_app_render(width, height, dtime())) {
        SwapBuffers(win_dc);
        if (!fullscreen) {
            // If user has changed window size, wait until it stops 
            // changing and then write the new dimensions to file
            //
            if ((rt.left != rect.left) || (rt.top != rect.top) || 
                (rt.right != rect.right) || (rt.bottom != rect.bottom)
            ) {
				if (IsZoomed(window)) return;
				if ((rt.left < 0) && (rt.right < 0)) return;
				if ((rt.top < 0) && (rt.bottom < 0)) return;
                size_changed = 1;
                rect.left = rt.left;
                rect.top = rt.top;
                rect.right = rt.right;
                rect.bottom = rt.bottom;
            } else {
                if (size_changed && (++size_changed > 10)) {
                    size_changed = 0;
                    FILE *f = boinc_fopen("gfx_info", "w");
                    if (f) {
                        // ToDo: change this to XML
                        fprintf(f, "%d %d %d %d\n",
                            rect.left, rect.top, rect.right, rect.bottom
                        );
                        fclose(f);
                    }
                }
            }               // End if (new size != previous size) else 
        }
    }
}
コード例 #22
0
ファイル: sperrer.c プロジェクト: Kebap/mg-mudlib
debug(what,arg)
{
  string log;
  
  if (!environment())
    return;
  log=sprintf("%s %s %O PO=%O PPO=%O TO=%O TI=%O verb=%O\n",
      dtime(time()), what, arg, 
      previous_object(), previous_object(1), 
      this_object(), this_interactive(), 
      (this_interactive()||this_player()||this_object())->_unparsed_args());
  log_file("NDEAD",log);
  
  if (find_player("jof"))
    tell_object(find_player("jof"),log);
  if (previous_object() && 
      (!interactive(PO)||IS_LEARNER(PO)) && 
      getuid(PO)!=ROOTID && PO!=this_object())
  {
    log_file("NDEAD",sprintf("DELETED %O\n",PO));
    catch(PO->remove());
コード例 #23
0
ファイル: main.cpp プロジェクト: gchilders/boinc
// Log informational messages to system specific places
//
void log_message_startup(const char* msg) {
    char evt_msg[2048];
    char* time_string = time_to_string(dtime());

    snprintf(evt_msg, sizeof(evt_msg),
             "%s %s\n",
             time_string, msg
            );
    if (!gstate.executing_as_daemon) {
        fprintf(stdout, "%s", evt_msg);
    } else {
#ifdef _WIN32
        LogEventInfoMessage(evt_msg);
#elif defined(__EMX__)
#elif defined (__APPLE__)
#elif defined (ANDROID)
        __android_log_print(ANDROID_LOG_INFO, "BOINC", evt_msg);
#else
        syslog(LOG_DAEMON|LOG_INFO, "%s", evt_msg);
#endif
    }
}
コード例 #24
0
ファイル: main.cpp プロジェクト: gchilders/boinc
// Some dual-GPU laptops (e.g., Macbook Pro) don't power down
// the more powerful GPU until all applications which used them exit.
// To save battery life, the client launches a second instance
// of the client as a child process to detect and get info
// about the GPUs.
// The child process writes the info to a temp file which our main
// client then reads.
//
static void do_gpu_detection(int argc, char** argv) {
    vector<string> warnings;

    boinc_install_signal_handlers();
    gstate.parse_cmdline(argc, argv);
    gstate.now = dtime();

    int flags =
        BOINC_DIAG_DUMPCALLSTACKENABLED |
        BOINC_DIAG_HEAPCHECKENABLED |
        BOINC_DIAG_TRACETOSTDOUT |
        BOINC_DIAG_REDIRECTSTDERR |
        BOINC_DIAG_REDIRECTSTDOUT;

    diagnostics_init(flags, "stdoutgpudetect", "stderrgpudetect");

    read_config_file(true);

    coprocs.detect_gpus(warnings);
    coprocs.write_coproc_info_file(warnings);
    warnings.clear();
}
コード例 #25
0
ファイル: main.cpp プロジェクト: gchilders/boinc
void log_message_error(const char* msg, int error_code) {
    char evt_msg[2048];
    char* time_string = time_to_string(dtime());
    snprintf(evt_msg, sizeof(evt_msg),
             "%s %s\n"
             "Error Code: %d\n",
             time_string, msg, error_code
            );
    if (!gstate.executing_as_daemon) {
        fprintf(stderr, "%s", evt_msg);
    } else {
#ifdef _WIN32
        LogEventErrorMessage(evt_msg);
#elif defined(__EMX__)
#elif defined (__APPLE__)
#elif defined (ANDROID)
        __android_log_print(ANDROID_LOG_ERROR, "BOINC", evt_msg);
#else
        syslog(LOG_DAEMON|LOG_ERR, "%s", evt_msg);
#endif
    }
}
コード例 #26
0
ファイル: openclapp.hpp プロジェクト: Ashod/Boinc
void update_shmem() {
    if (!shmem) return;

    // always do this; otherwise a graphics app will immediately
    // assume we're not alive
    shmem->update_time = dtime();

    // Check whether a graphics app is running,
    // and don't bother updating shmem if so.
    // This doesn't matter here,
    // but may be worth doing if updating shmem is expensive.
    //
    if (shmem->countdown > 0) {
        // the graphics app sets this to 5 every time it renders a frame
        shmem->countdown--;
    } else {
        return;
    }
    shmem->fraction_done = boinc_get_fraction_done();
    shmem->cpu_time = boinc_worker_thread_cpu_time();;
    boinc_get_status(&shmem->status);
}
コード例 #27
0
ファイル: linpack.c プロジェクト: tomari/microbench
static REAL linpack(long nreps,int arsize)

    {
    REAL  *a,*b;
    REAL   norma,t1,kflops,tdgesl,tdgefa,totalt,toverhead,ops;
    int   *ipvt,n,info,lda;
    long   i,arsize2d;

    lda = arsize;
    n = arsize/2;
    arsize2d = (long)arsize*(long)arsize;
    ops=((2.0*n*n*n)/3.0+2.0*n*n);
    a=(REAL *)mempool;
    b=a+arsize2d;
    ipvt=(int *)&b[arsize];
    tdgesl=0;
    tdgefa=0;
    totalt=dtime();
    for (i=0;i<nreps;i++)
        {
        matgen(a,lda,n,b,&norma);
        t1 = dtime();
        dgefa(a,lda,n,ipvt,&info,roll);
        tdgefa += dtime()-t1;
        t1 = dtime();
        dgesl(a,lda,n,ipvt,b,0,roll);
        tdgesl += dtime()-t1;
        }
    totalt=dtime()-totalt;
    if (totalt<0.5 || tdgefa+tdgesl<0.2)
        return(0.);
    kflops=nreps*ops/(1000.*(tdgefa+tdgesl));
    toverhead=totalt-tdgefa-tdgesl;
    if (tdgefa<0.)
        tdgefa=0.;
    if (tdgesl<0.)
        tdgesl=0.;
    if (toverhead<0.)
        toverhead=0.;
    printf("%8ld %6.2f %6.2f%% %6.2f%% %6.2f%%  %9.3f\n",
            nreps,totalt,100.*tdgefa/totalt,
            100.*tdgesl/totalt,100.*toverhead/totalt,
            kflops);
    return(totalt);
    }
コード例 #28
0
ファイル: tempname.c プロジェクト: prajwal83/upanapps
static void brain_damaged_fillrand(unsigned char *buf, unsigned int len)
{
	int i, k;
	uint32_t high, low, rh;
	static uint64_t value;
	RTCTime rtcTime ;
	dtime(&rtcTime) ;
	value += ((uint64_t) rtcTime.bSecond << 16) ^ rtcTime.bSecond ^ getpid();
	low = value & UINT32_MAX;
	high = value >> 32;
	for (i = 0; i < len; ++i) {
		rh = high % 62;
		high /= 62;
#define L ((UINT32_MAX % 62 + 1) % 62)
		k = (low % 62) + (L * rh);
#undef L
#define H ((UINT32_MAX / 62) + ((UINT32_MAX % 62 + 1) / 62))
		low = (low / 62) + (H * rh) + (k / 62);
#undef H
		k %= 62;
		buf[i] = letters[k];
	}
}
コード例 #29
0
ファイル: x_opengl.cpp プロジェクト: FpgaAtHome/seti_fpga
// maybe_render() can be called directly by GLUT when a window is 
// uncovered, so we let that happen even if suspend_render is true.
static void maybe_render() {
    int width, height;
    BOINC_STATUS boinc_status;

    if (visible && (current_graphics_mode != MODE_HIDE_GRAPHICS)) {
        width = glutGet(GLUT_WINDOW_WIDTH);
        height = glutGet(GLUT_WINDOW_HEIGHT);
        if (throttled_app_render(width, height, dtime())) {
            glutSwapBuffers();
#ifdef __APPLE__
            switch (current_graphics_mode) {
            case MODE_WINDOW:
                MacGLUTFix(false);
                if (need_show) {
                    glutShowWindow();
                    need_show = false;
                }
                break;
            case MODE_FULLSCREEN:
            case MODE_BLANKSCREEN:
                MacGLUTFix(true);
                if (need_show) {
                    glutShowWindow();
                    need_show = false;
                }
                break;
            }
#endif
            // Always render once after app is suspended in case app displays
            //  different graphics when suspended, then stop rendering
            boinc_get_status(&boinc_status);
            if (boinc_status.suspended)
                suspend_render = true;
        }
    }
}
コード例 #30
0
ファイル: main.cpp プロジェクト: gchilders/boinc
static void init_core_client(int argc, char** argv) {
    setbuf(stdout, 0);
    setbuf(stderr, 0);

    cc_config.defaults();
    gstate.parse_cmdline(argc, argv);
    gstate.now = dtime();

#ifdef _WIN32
    if (!cc_config.allow_multiple_clients) {
        chdir_to_data_dir();
    }
#endif

#ifndef _WIN32
    if (g_use_sandbox)
        // Set file creation mask to be writable by both user and group and
        // world-executable but neither world-readable nor world-writable
        // Our umask will be inherited by all our child processes
        //
        umask (6);
#endif

    // Initialize the BOINC Diagnostics Framework
    int flags =
#ifdef _DEBUG
        BOINC_DIAG_MEMORYLEAKCHECKENABLED |
#endif
        BOINC_DIAG_DUMPCALLSTACKENABLED |
        BOINC_DIAG_HEAPCHECKENABLED |
        BOINC_DIAG_TRACETOSTDOUT;

    if (gstate.redirect_io || gstate.executing_as_daemon || gstate.detach_console) {
        flags |=
            BOINC_DIAG_REDIRECTSTDERR |
            BOINC_DIAG_REDIRECTSTDOUT;
    }

    diagnostics_init(flags, "stdoutdae", "stderrdae");

#ifdef _WIN32
    // Specify which allocation will cause a debugger to break.  Use a previous
    // memory leak detection report which looks like this:
    //   {650} normal block at 0x000000000070A6F0, 24 bytes long.
    //   Data: <  N     P p     > 80 1E 4E 00 00 00 00 00 50 AE 70 00 00 00 00 00
    //_CrtSetBreakAlloc(650);
    //_CrtSetBreakAlloc(651);
    //_CrtSetBreakAlloc(652);
    //_CrtSetBreakAlloc(653);
    //_CrtSetBreakAlloc(654);
#endif

    read_config_file(true);

    // Win32 - detach from console if requested
#ifdef _WIN32
    if (gstate.detach_console) {
        FreeConsole();
    }
#endif

    // Unix: install signal handlers
#ifndef _WIN32
    // Handle quit signals gracefully
    boinc_set_signal_handler(SIGHUP, (handler_t)signal_handler);
    boinc_set_signal_handler(SIGINT, (handler_t)signal_handler);
    boinc_set_signal_handler(SIGQUIT, (handler_t)signal_handler);
    boinc_set_signal_handler(SIGTERM, (handler_t)signal_handler);
#ifdef SIGPWR
    boinc_set_signal_handler(SIGPWR, (handler_t)signal_handler);
#endif
#endif
}