示例#1
0
int main(int argc, char * argv[])
{
    int n, n_threads = 0;
    matrix_t * A,
             * A_orig;
    vector_t * b,
             * b_orig,
             * x,
             * check_res_mat;
             
    double t_start, t_end;
    
    
    get_input_params(argc, argv, &n);
    initialize_global_state();
    
    /* initialize data */
    A_orig          = matrix_create_rand(n, n),
    A               = matrix_clone(A_orig),
    b_orig          = vector_create_rand(n),
    b               = vector_clone(b_orig),
    x               = vector_create(n),
    check_res_mat   = vector_create(n);
    
    t_start = get_time_in_sec();
    
    perform_gaussian_elimination_on_matrix(A, b);
    perform_back_substitution(A, x, b);
    
    t_end  = get_time_in_sec();
    
    /* calculate Ax - b and find it's l2norm to test for correctness */
    matrix_mult_vector(A_orig, x, check_res_mat);
    
    vector_subtract(check_res_mat, check_res_mat, b_orig); /* c = c - b */
    
    printf("num-procs   = %d\n", omp_get_num_procs());

#pragma omp parallel num_threads(num_threads)
#pragma omp single
    n_threads = omp_get_num_threads();

    printf("num-threads = %d\n", n_threads);

    printf("Performed Gaussian Elimination in %.12lfs\n", t_end - t_start);
    printf("Ax-b l2norm = %.6le\n", vector_l2norm(check_res_mat));
    
    puts("done");   
    return 0;
}
static inline int msm_rpmstats_append_data_to_buf(char *buf,
		struct msm_rpm_stats_data_v2 *data, int buflength)
{
	char stat_type[5];
	u64 time_in_last_mode;
	u64 time_since_last_mode;
	u64 actual_last_sleep;

	stat_type[4] = 0;
	memcpy(stat_type, &data->stat_type, sizeof(u32));

	time_in_last_mode = data->last_exited_at - data->last_entered_at;
	time_in_last_mode = get_time_in_msec(time_in_last_mode);
	time_since_last_mode = arch_counter_get_cntpct() - data->last_exited_at;
	time_since_last_mode = get_time_in_sec(time_since_last_mode);
	actual_last_sleep = get_time_in_msec(data->accumulated);

	return  snprintf(buf , buflength,
		"RPM Mode:%s\n\t count:%d\ntime in last mode(msec):%llu\n"
		"time since last mode(sec):%llu\nactual last sleep(msec):%llu\n"
		"client votes: %#010x\n\n",
		stat_type, data->count, time_in_last_mode,
		time_since_last_mode, actual_last_sleep,
		data->client_votes);
}
示例#3
0
static int __devinit stm_sbc_rtc_probe(struct platform_device *pdev)
{
	struct stm_sbc_rtc *rtc;
	int ret = 0;

	rtc = devm_kzalloc(&pdev->dev,
		sizeof(struct stm_sbc_rtc), GFP_KERNEL);
	if (unlikely(!rtc))
		return -ENOMEM;

	rtc_time_to_tm(get_time_in_sec(), &rtc->tm_cur);

	device_set_wakeup_capable(&pdev->dev, 1);
	platform_set_drvdata(pdev, rtc);

	rtc->rtc_dev = rtc_device_register(DRV_NAME, &pdev->dev,
		&stm_sbc_rtc_ops, THIS_MODULE);
	if (IS_ERR(rtc->rtc_dev)) {
		ret = PTR_ERR(rtc->rtc_dev);
		goto err_badreg;
	}

	return ret;

err_badreg:
	device_set_wakeup_capable(&pdev->dev, 0);
	platform_set_drvdata(pdev, NULL);
	return ret;
}
static int rpm_stats_resume(struct device *dev)
{
	void __iomem *reg =0;
	struct msm_rpm_stats_data_v2 data;
	int i, length;
	char stat_type[5];
	u64 time_in_last_mode;
	u64 time_since_last_mode;
	u64 actual_last_sleep;

	reg = ioremap_nocache(g_phys_addr_base, g_phys_size);
	if(!reg) {
		return 0;
	}

	for (i = 0, length = 0; i < 2; i++) {
		data.stat_type = msm_rpmstats_read_long_register_v2(reg, i,
				offsetof(struct msm_rpm_stats_data_v2, stat_type));
		data.count = msm_rpmstats_read_long_register_v2(reg, i,
				offsetof(struct msm_rpm_stats_data_v2, count));
		data.last_entered_at = msm_rpmstats_read_quad_register_v2(reg, i, 
				offsetof(struct msm_rpm_stats_data_v2, last_entered_at));
		data.last_exited_at = msm_rpmstats_read_quad_register_v2(reg, i,
				offsetof(struct msm_rpm_stats_data_v2, last_exited_at));
		data.accumulated = msm_rpmstats_read_quad_register_v2(reg, i, 
				offsetof(struct msm_rpm_stats_data_v2, accumulated));
		if(0 == i) {
			data.client_votes = msm_rpmstats_read_quad_register_v2(reg,	i, 
					offsetof(struct msm_rpm_stats_data_v2, client_votes));
			data.subsystem_votes = msm_rpmstats_read_quad_register_v2(reg, i, 
					offsetof(struct msm_rpm_stats_data_v2, subsystem_votes));
		}

		stat_type[4] = 0;
		memcpy(stat_type, &data.stat_type, sizeof(u32));

		time_in_last_mode = data.last_exited_at - data.last_entered_at;
		time_in_last_mode = get_time_in_msec(time_in_last_mode);
		time_since_last_mode = arch_counter_get_cntpct() - data.last_exited_at;
		time_since_last_mode = get_time_in_sec(time_since_last_mode);
		actual_last_sleep = get_time_in_msec(data.accumulated);

		if(0 == i) {
			printk("[RPM] Resume: RPM Mode:%s\n\t count:%d\n time in last mode(msec):%llu\n"
				"time since last mode(sec):%llu\n actual last sleep(msec):%llu\n"
				"Client votes: 0x%x, Subsystem votes: 0x%x\n",
				stat_type, data.count, time_in_last_mode,
				time_since_last_mode, actual_last_sleep, 
				data.client_votes, data.subsystem_votes);
		}
		else {
			printk("[RPM] Resume: RPM Mode:%s\n\t count:%d\n time in last mode(msec):%llu\n"
				"time since last mode(sec):%llu\n actual last sleep(msec):%llu\n",
				stat_type, data.count, time_in_last_mode,
				time_since_last_mode, actual_last_sleep);
		}
	}
示例#5
0
static int stm_sbc_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	unsigned long lpt;
	unsigned long lpt_cur;
	struct stm_sbc_rtc *rtc = dev_get_drvdata(dev);

	lpt = get_time_in_sec();
	rtc_tm_to_time(&rtc->tm_cur, &lpt_cur);
	rtc_time_to_tm(lpt, tm);

	if (lpt < lpt_cur)
		lpt = lpt - lpt_cur;
	rtc_time_to_tm(lpt, &rtc->tm_cur);

	return 0;
}
示例#6
0
static int stm_sbc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
{
	int ret = 0;
	unsigned long lpt;
	struct stm_sbc_rtc *rtc = dev_get_drvdata(dev);

	rtc_tm_to_time(&t->time, &lpt);
	lpt = lpt - get_time_in_sec();
	rtc_time_to_tm(lpt, &t->time);

	memcpy(&rtc->alarm, t, sizeof(struct rtc_wkalrm));

	ret = stm_lpm_set_wakeup_time(lpt);
	if (ret < 0)
		return ret;

	device_set_wakeup_enable(dev, true);

	return 0;
}