Пример #1
0
static void *worker_pipeline(void *shared, int step, void *_data)
{
	int i;
	ta_opt_t *opt = (ta_opt_t*)shared;
	if (step == 0) {
		data_for_t *ret;
		ret = calloc(1, sizeof(data_for_t));
		ret->seqs = bseq_read(opt->ks, opt->chunk_size, &ret->n_seqs);
		ret->opt = opt;
		if (ret->seqs) return ret;
		else free(ret);
	} else if (step == 1) {
		data_for_t *data = (data_for_t*)_data;
		kt_for(opt->n_threads, worker_for, data, data->n_seqs);
		return data;
	} else if (step == 2) {
		data_for_t *data = (data_for_t*)_data;
		for (i = 0; i < data->n_seqs; ++i) {
			bseq1_t *s = &data->seqs[i];
			putchar(s->qual? '@' : '>'); puts(s->name);
			puts(s->seq);
			if (s->qual) {
				puts("+"); puts(s->qual);
			}
			free(s->seq); free(s->qual); free(s->name);
		}
		free(data->seqs); free(data);
	}
	return 0;
}
Пример #2
0
int main(int argc, char *argv[])
{
	int i, tmp, tot, type = 0, n_threads = 2;
	global_t global = { 10240*100, 800, 600, -2., -1.2, -1.2, 1.2, 0 };
//	global_t global = { 10240*1, 8, 6, -2., -1.2, -1.2, 1.2, 0 };

	if (argc > 1) {
		type = argv[1][0] == 'o'? 2 : argv[1][0] == 'c'? 3 : argv[1][0] == 'n'? 1 : 0;
		if (argv[1][0] >= '0' && argv[1][0] <= '9')
			n_threads = atoi(argv[1]);
	} else {
		fprintf(stderr, "Usage: ./a.out [openmp | cilk | #threads]\n");
	}
	tot = global.w * global.h;
	global.k = calloc(tot, sizeof(int));
	for (i = 0; i < tot; ++i) global.k[i] = -1;
	if (type == 0) {
		kt_for(n_threads, compute, &global, tot);
	} else if (type == 2) {
		#pragma omp parallel for
		for (i = 0; i < tot; ++i)
			compute(&global, i, 0);
	} else if (type == 3) {
		#if HAVE_CILK
		cilk_for (i = 0; i < tot; ++i)
			compute(&global, i, 0);
		#endif
	}