コード例 #1
0
ファイル: test.cpp プロジェクト: 8l/kalmar
bool test(accelerator_view &rv)
{
    int data[] = {0, 0, 0, 0};
    vector<int> Flags(data, data + sizeof(data) / sizeof(int));
    extent<1> eflags(sizeof(data) / sizeof(int));
    array<int, 1> aFlag(eflags, Flags.begin(), rv);

    const int size = 100;

    vector<int> A(size);
    vector<c> G(size);
    vector<c> G2(size);

    for(int i = 0; i < size; i++)
    {
        A[i] = INIT_VALUE;
        G[i].i = G[i].d = G[i].ui = G[i].f = i;
        G2[i].i = G2[i].d = G2[i].ui = G2[i].f = i;
    }

    extent<1> e(size);
    extent<2> eG(10, 10);

    array<int, 1> aA(e, A.begin(), rv);
    array<c, 2> aG(eG, G.begin(), rv);
    array<c, 2> aG2(eG, G2.begin(), rv);

    parallel_for_each(aA.get_extent(), [&](index<1>idx) __GPU
    {
        c *p = NULL;

        if (aFlag[0] == 0)
            p = &aG[0][0];
        else
            p = &aG2[0][0];

        double di = 0;
        for (int i = 0; i < 100; i++)
        {
            if (!Equal((*p).i, (int)i) || !Equal((*p).d, di) || !Equal((*p).ui, (unsigned __int32)i) || !Equal((*p).f, (float)i))
            {
                aA[idx] = 1;
            }
            p++;
            di++;
        }
    });
コード例 #2
0
ファイル: klog.c プロジェクト: HarryR/sanos
static void release_klog_waiters(void *arg) {
  struct klogreq *waiter;

  // Defer scheduling of kernel log waiter if we are in a interrupt handler
  if ((eflags() & EFLAG_IF) == 0)  {
    queue_irq_dpc(&klog_dpc, release_klog_waiters, NULL);
    return;
  }

  waiter = klog_waiters;
  while (waiter) {
    waiter->rc = 0;
    mark_thread_ready(waiter->thread, 1, 2);
    waiter = waiter->next;
  }

  klog_waiters = NULL;
}
コード例 #3
0
ファイル: test.cpp プロジェクト: pathscale/amp-testsuite
bool test(accelerator_view &rv)
{
    int data[] = {0, 0, 0, 0};
    vector<int> Flags(data, data + sizeof(data) / sizeof(int));
    extent<1> eflags(sizeof(data) / sizeof(int));
    Concurrency::array<int, 1> aFlag(eflags, Flags.begin(), rv);

    const int size = 100;

    vector<int> A(size);

    for(int i = 0; i < size; i++)
    {
        A[i] = INIT_VALUE;
    }

    extent<1> e(size);

    Concurrency::array<int, 1> aA(e, A.begin(), rv);

    parallel_for_each(aA.get_extent().tile<1>(), [&](tiled_index<1>idx) __GPU_ONLY
    {
        tile_static type v1, v2;

        v1 = 0;
        v2 = 0;

        type *p;
        if (aFlag[0] == 0)
            p = &v1;
        else 
            p = &v2;

        *p = (type)1;

        if (!Equal(v1, (type)1))
            aA[idx] = 1;
    });
コード例 #4
0
ファイル: cycle.c プロジェクト: columbia/cr-tests
int main(int argc, char **argv)
{
	char rbuf[128];
	struct epoll_event ev;
	int op_num = 0;
	int pfd[2];
	int efd[3];
	int ec = EXIT_FAILURE;
	int ret, i, j;

	parse_args(argc, argv);

	/* FIXME eventually stdio streams should be harmless */
	close(0);
	logfp = fopen(LOG_FILE, "w+");
	if (!logfp) {
		perror("could not open logfile");
		exit(1);
	}
	/* redirect stdout and stderr to the log file */
	if (dup2(fileno(logfp), 1) < 0) {
		log_error("dup2(logfp, 1)");
		goto out;
	}
	if (dup2(fileno(logfp), 2) < 0) {
		log_error("dup2(logfp, 2)");
		goto out;
	}
	if (!move_to_cgroup("freezer", freezer, getpid())) {
		log_error("move_to_cgroup");
		exit(2);
	}

	ret = pipe(pfd);
	if (ret < 0)
		goto out;
	log("INFO", "pipe read fd: %d, pipe write fd: %d\n",
	    pfd[0], pfd[1]);

label(create_efd, ret, ret + 0);
	ev.events = EPOLLOUT|EPOLLIN|EPOLLET;
	for (i = 0; i < num_efd; i++) {
		efd[i] = epoll_create(4);
		if (efd[i] < 0) {
			log("FAIL", "efd[i] = epoll_create(3);");
			ret = efd[i];
			goto out;
		}
		if (i == 0)
			continue;
		ev.data.fd = efd[i - 1];
		ret = epoll_ctl(efd[i], EPOLL_CTL_ADD, ev.data.fd, &ev);
		if (ret < 0) {
			log("FAIL", "epoll_ctl(efd[i] (%d), EPOLL_CTL_ADD, ev.data.fd (%d), &ev);", efd[i], ev.data.fd);
			goto out;
		}
	}

	/* Close the cycle */
	ev.data.fd = efd[num_efd - 1];
	ret = epoll_ctl(efd[0], EPOLL_CTL_ADD, ev.data.fd, &ev);
	if (ret < 0) {
		log("FAIL",
		"epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev);");
		goto out;
	}

label(link_pipe, ret, ret + 0);
	/*
	 * Now put the pipe fds "last" set of the cycle. For example:
	 *
	 * /---------------------------------\
	 * |                                 |
	 * \- efd[0] <-- efd[1] <-- efd[2] <-/
	 *                            | |
	 *                            | \--> pfd[0]
	 *                            \----> pfd[1]
	 *
	 * Where foo --> bar means that foo has bar in its set.
	 */
	ev.events = EPOLLIN;
	ev.data.fd = pfd[0];
	ret = epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev);
	if (ret < 0) {
		log("FAIL",
		"epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, pfd[0], &ev);");
		goto out;
	}
	ev.events = EPOLLOUT;
	ev.data.fd = pfd[1];
	ret = epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev);
	if (ret < 0) {
		log("FAIL",
		"epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, pfd[1], &ev);");
		goto out;
	}

label(wait_write, ret, ret + 0);
	/*
	 * Since it's a cycle of epoll sets, we have to wait on the
	 * other epoll sets to get the event that triggered EPOLLIN
	 * on this set. Start with the epoll fd which will take us the
	 * long way around the cycle: efd[num_efd - 2].
	 */

	/* The index of the previous epoll fd in the cycle */
	j = num_efd - 1;
	for (i = num_efd - 2; i > -1; i--) {
		/* The index of the previous epoll fd in the cycle */
		j = (unsigned int)(i - 1) % ~(num_efd - 1);
		log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[i], efd[j]);
		ret = epoll_wait(efd[i], &ev, 1, 1000);
		if (ret != 1) {
			log_error("Expected epoll_wait() to return an event.\n");
			goto out;
		}
		log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events));
		if ((ev.data.fd != efd[j]) || !(ev.events & EPOLLIN))
			goto out;
	}

	/*
	 * Now we expect the actual event indicating it's ok to write
	 * output.
	 */
	log("INFO", "Waiting on %d for EPOLLOUT on %d\n", efd[j], pfd[1]);
	ret = epoll_wait(efd[j], &ev, 1, 1000);
	if (ret != 1) {
		log_error("Expected epoll_wait() to return an event.\n");
		goto out;
	}
	log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events));
	if ((ev.data.fd != pfd[1]) || !(ev.events & EPOLLOUT))
		goto out;
label(do_write,
	ret, write(pfd[1], HELLO, strlen(HELLO) + 1));
	if (ret < (int)(strlen(HELLO) + 1)) {
		log("FAIL", "Unable to write all %zu bytes of \"%s\" to %d\n",
			 strlen(HELLO) + 1, HELLO, pfd[0]);
		goto out;
	}

label(wait_read, ret, ret + 0);
	/* The index of the previous epoll fd in the cycle */
	j = num_efd - 1;
	for (i = num_efd - 2; i > -1; i--) {
		/* The index of the previous epoll fd in the cycle */
		j = (unsigned int)(i - 1) % ~(num_efd - 1);
		log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[i], efd[j]);
		ret = epoll_wait(efd[i], &ev, 1, 1000);
		if (ret != 1) {
			log_error("Expected epoll_wait() to return an event.\n");
			goto out;
		}
		log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events));
		if ((ev.data.fd != efd[j]) || !(ev.events & EPOLLIN))
			goto out;
	}
	log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[j], pfd[0]);
	ret = epoll_wait(efd[j], &ev, 1, 1000);
	if (ret != 1) {
		log_error("Expected epoll_wait() to return an event.\n");
		goto out;
	}
	log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events));
	if ((ev.data.fd != pfd[0]) || !(ev.events & EPOLLIN))
		goto out;

label(do_read, ret, ret + 0);
	ret = read(pfd[0], rbuf, strlen(HELLO) + 1);
	if (ret < (int)(strlen(HELLO) + 1)) {
		log("FAIL", "Unable to read all %zu bytes of \"%s\"\n",
			 strlen(HELLO) + 1, HELLO);
		goto out;
	}
	if (strcmp(HELLO, rbuf)) {
		log("FAIL", "File was corrupted. Expected: \"%s\" Got: \"%s\"\n",
			 HELLO, rbuf);
		goto out;
	}
	log("INFO", "read len ok\n");
	log("INFO", "read pipe contents ok\n");
	ec = EXIT_SUCCESS;
	op_num = INT_MAX;

out:
	if (op_num != INT_MAX) {
		log("FAIL", "error at label %s (op num: %d)\n",
			  labels[op_num], op_num);
	}
	for (i = 0; i < num_efd; i++) {
		ret = close(efd[i]);
		efd[i] = -1;
		if (ret < 0)
			log_error("close(efd[i])");
	}
	if (pfd[0]) {
		close(pfd[0]);
		close(pfd[1]);
	}
	fflush(logfp);
	fclose(logfp);
	exit(ec);
}
コード例 #5
0
ファイル: test.cpp プロジェクト: pathscale/amp-testsuite
bool test(accelerator_view &rv)
{
    int data[] = {0, 0, 0, 0};
    vector<int> Flags(data, data + sizeof(data) / sizeof(int));
    extent<1> eflags(sizeof(data) / sizeof(int));
    array<int, 1> aFlag(eflags, Flags.begin(), rv);

    const int size = 100;

    vector<int> A(size);

    for(int i = 0; i < size; i++)
    {
        A[i] = INIT_VALUE;
    }

    extent<1> e(size);

    array<int, 1> aA(e, A.begin(), rv);

    parallel_for_each(aA.extent, [&](index<1>idx) __GPU
    {
        type arr[10];

        arr[0] = 0; arr[1] = 1; arr[2] = 2; arr[3] = 3; arr[4] = 4; 
        arr[5] = 5; arr[6] = 6; arr[7] = 7; arr[8] = 8; arr[9] = 9;

        type *p = NULL;

        if (aFlag[0] == 0)
            p = &arr[0];
        else
            p = &arr[1];

        p++;

        type *p2 = p;

        if (!Equal(*p2, (type)1))
            aA[idx] = 1;

        p2--;

        type *p3 = p2;

        if (!Equal(*p3, (type)0))
            aA[idx] = 1;

        p = &arr[0];

        if (aFlag[0] == 0)
            p2 = &arr[9];
        else
            p2 = &arr[8];

        int diff = p2 - p;

        if ((diff != 9) || (diff != (&arr[9] - &arr[0])))
            aA[idx] = 1;

        p2 = p + 9;

        if (!Equal(*p2, (type)9))
            aA[idx] = 1;
    });