Ejemplo n.º 1
0
static int
syf_pwm_ioctl(struct inode *inode, struct file *file,
              unsigned int cmd, void *arg)
{
    int i;
    unsigned int freq;
    cpu_ctrl_t *cc				= (cpu_ctrl_t *) arg;
    pmu_results_t *r 			= &(cc->pmu);
    unsigned int amt_cpu 		= cc->amt_cpu;
    unsigned int amt_counter 	= cc->amt_counter;

    for (i = 0; i < amt_cpu; ++i) {
        struct syf_info_t *_sinfo = &per_cpu(_syf_info, i);

        switch (cmd) {
        case SYFPWM_TESTING:
            printk("TESTING.\n");
            break;

        case SYFPWM_PMU_START:
            pmu_start(amt_counter, cc->evt_t);
            break;

        case SYFPWM_PMU_STOP:
            pmu_stop(amt_counter);
            memcpy(r, &pmu, sizeof(pmu_results_t));
            break;

        case SYFPWM_GET_FEQU:
            mutex_lock(&_syf_mutex);
            cpufreq_get_policy(&_sinfo->cur_policy, i);
            freq = cpufreq_get(_sinfo->cur_policy.cpu);
            mutex_unlock(&_syf_mutex);
            break;

        case SYFPWM_SET_FEQU:
            mutex_lock(&_syf_mutex);
            cpufreq_get_policy(&_sinfo->cur_policy, i);
            freq = __cpufreq_driver_target(&_sinfo->cur_policy,
                                           (unsigned int) cc->cpu_freq,
                                           CPUFREQ_RELATION_H);
            mutex_unlock(&_syf_mutex);
            break;
        }
    }

    return 0;
}
Ejemplo n.º 2
0
void
setup_output()
{
    char hdr[1024];
    hdr[sizeof(hdr)-1] = 0;

    pmu_init();
    pmu_start();
    for (int i = 0; i < NGBOXES; ++i)
        for (int j = 0; j < 2; ++j)
        {
            prevnreads += pmu_rdctr(i, j, 0);
            prevnwrites += pmu_rdctr(i, j, 1);
        }
    double ibw = (gbl.ncores-1) * 2 * gbl.hz;
    labels[fInst].max = ibw;
    labels[fVPU].max = ibw;
    double vop = (gbl.ncores-1) * 8 * gbl.hz;
    labels[fVpuSP].max = 2*vop;
    labels[fVpuDP].max = vop;

    // order doesn't really matter but we're used to this and it's better
    // for Excel
    hdrLabels[0] = "Time";
    hdrLabels[1] = "Threads";
    hdrIndexes[0] = fTime;
    hdrIndexes[1] = fThreads;
    int j = 2;
    for (int i = 0; i < nfields; ++i)
        if (i != fTime && i != fThreads)
        {
            hdrLabels[j] = labels[i].name;
            hdrIndexes[j] = i;
            ++j;
        }
    hdr[0] = 0;
    hdr[sizeof(hdr)-1] = 0;
    bool first = true;
    for (int i = 0; i < nfields; ++i)
    {
        if (first)
            first = false;
        else
            strncat(hdr, ",", sizeof(hdr)-1);
        strncat(hdr, hdrLabels[i], sizeof(hdr)-1);
    }
    strncat(hdr, "\n", sizeof(hdr)-1);

    if (gbl.server)
    {
        setup_server();
    }
    else if (gbl.outfile)
    {
        outfile = fopen(gbl.outfile, "w");
        if (outfile == NULL)
            err(1, "create %s", gbl.outfile);
    }

    gbl.hdr[0] = 0;
    gbl.hdr[sizeof(gbl.hdr)-1] = 0;
    if (gbl.server)
    {
        for (int i = 0; i < nfields; ++i)
            if (i != fTime)
                snprintf(gbl.hdr+strlen(gbl.hdr), sizeof(gbl.hdr)-1,
                    "%s=%g,%s,%g\n",
                    labels[i].name,
                    labels[i].max,
                    labels[i].units,
                    labels[i].factor);
        strncat(gbl.hdr, hdr, sizeof(gbl.hdr)-1);
    }
    else if (outfile)
    {
        for (int i = 0; i < nfields; ++i)
            if (i != fTime)
                fprintf(outfile, "%s=%g,%s,%g\n",
                    labels[i].name,
                    labels[i].max,
                    labels[i].units,
                    labels[i].factor);
        fprintf(outfile, hdr);
    }
    starttsc = _rdtsc();
}
Ejemplo n.º 3
0
static int pmu_resume(struct sys_device *dev)
{
	if (pmu_enabled)
		pmu_start();
	return 0;
}
Ejemplo n.º 4
0
int do_experiment(struct list *list, char *store_name, unsigned long rec_num, 
			unsigned long rec_size, int op)
{
	struct timespec stamp_s, stamp_e;
	unsigned long tv_sec, tv_nsec;
	struct node *node;
	unsigned long long tmp_key[2];
	unsigned long long *tmp_value;
	DBT key, value;
	unsigned long cnt, i;
	int rval;

	tmp_value = (unsigned long long *)malloc(rec_size);
	node = list->head;
	cnt = 1;
	
	memset(&key, 0, sizeof(DBT));
	memset(&value, 0, sizeof(DBT));

	key.data = tmp_key;
	key.size = 16;
	value.data = tmp_value;
	value.size = rec_size;
	value.ulen = rec_size;
	value.flags = DB_DBT_USERMEM;

	clock_gettime(CLOCK_REALTIME, &stamp_s);
	pmu_start();
	while (node) {

		tmp_key[0] = tmp_key[1] = node->key;
		
		switch (op) {
			case INSERT:
				for (i=0; i<rec_size/8; i++) {
					tmp_value[i] = rec_num + node->key;
				}
				if (db->put(db, NULL, &key, &value, DB_NOOVERWRITE) != 0) {
					printf("[BDB] db->put() fail");
					return 0;
				}
				break;
				
			case LOOKUP:
				if (db->get(db, NULL, &key, &value, 0) != 0) {
					printf("[BDB] db->get() fail\n");
					return 0;
				} //else {
				//	tmp_value = (unsigned long *)value.data;
				//	if (tmp_value[0] != rec_num + node->key) {
				//		printf("[BDB] db->get(), wrong value!\n");
				//		return 0;
				//	}
				//}
				break;
				
			case DELETE:
				if (db->del(db, NULL, &key, 0) != 0) {
					printf("[BDB] db->del() fail\n");
					return 0;
				}
				break;

			case UPDATE:
				if (cnt%(FREQ_NUM+1) == 0) {
					if (db->del(db, NULL, &key, 0) != 0) {
						printf("[BDB] update: db->del() fail\n");
						return 0;
					}
				} else {
					for (i=0; i<rec_size/8; i++) {
						tmp_value[i] = rec_num + node->key;
					}
					if (db->put(db, NULL, &key, &value, DB_NOOVERWRITE) != 0) {
						printf("[BDB] update: db->put() fail\n");
						return 0;
					}
				}
				break;
				
			default:
				printf("Wrong operation!\n");
				return 0;
				//break;
		}

		node = node->next;
		cnt++;
		//if (cnt == rec_num)
		//	break;
	}
	pmu_stop();
	clock_gettime(CLOCK_REALTIME, &stamp_e);
	
	tv_sec = stamp_e.tv_sec - stamp_s.tv_sec;
	if (stamp_e.tv_nsec < stamp_s.tv_nsec) {
		stamp_e.tv_nsec += 1000000000;
		tv_sec--;
	}
	tv_nsec = stamp_e.tv_nsec - stamp_s.tv_nsec;
	printf("[BDB] Experiment Time (sec=%lu, nsec=%lu)\n", tv_sec, tv_nsec);

	free(tmp_value);
	return cnt-1;
}