Beispiel #1
0
MAINTYPE main()
	{
	void genxcmp(), getref(), gettest(), init() ;
	int recNum ;

	/* Read and interpret command-line arguments. */

	// init(argc, argv);

	for(recNum = 0; recNum < REC_COUNT; ++recNum)
		{
		sprintf(record,"%d",Records[recNum]) ;
      printf("%s\n",record) ;
		NewInit() ;


    /* Set A and T to the type and time of the first reference annotation after
       the end of the learning period. */
		do {
			getref();
			} while (T < start);

    /* Set aprime and tprime to the type and time of the first test annotation
       after the end of the learning period, and a and t to the type and time
		 of the last test annotation in the learning period. */
		do {
			gettest();
			} while (tprime < start);

	 /* If an extended output annotation file was requested, produce it and
		 exit. */
		if (Oflag) {
			genxcmp();
			wfdbquit();	//**
			exit(0);
			}

    /* If t matches the first reference annotation, count it and get the next
		 annotation from each file.  (Since T >= start and t < start, T-t must be
       positive.) */

		if (T-t < abs(T-tprime) && T-t <= match_dt)
			{
			if (A != 0 || a != 0)	/* false only if start = 0 */
				pair(A, a);
			getref();
			gettest();
			}

	 /* If there is a test annotation within an interval equal to the match
       window following the beginning of the test period, and there is no
       match, go on to the next test annotation without counting the first
       one. */

		else
			{
			gettest();
			if (t-start <= match_dt && abs(T-tprime) < abs(T-t))
				gettest();
			}

    /* Peform the comparison.  Each time through the loop below, a beat label
       pair is identified and counted (or else a non-beat annotation is
       discarded), and an annotation is read from each file from which an
		 annotation was paired or discarded.  Note that only one of the four
       numbered actions is performed on each iteration.

       The complex loop termination condition is dependent on end_time, which
       is not changed during execution of the loop.  There are three ways the
       loop termination condition can be satisfied:
       - If the length of the comparison is known, either because it was
         specified using the `-t' option or because the header file specifies
	 the record length, the loop ends when both T and t are greater than
	 end_time.  This is the usual case.
		 - If the length of the comparison is unknown (end_time = -1), the loop
         ends when EOF is reached in the reference annotation file (T =
	 huge_time).
       - If the option `-t 0' was specified (end_time = 0), the loop ends when
         EOF is first reached in either annotation file (T or t = huge_time).
    */
		while ((end_time > 0L && (T <= end_time || t <= end_time)) ||
			(end_time == -1L && T != huge_time) ||
			(end_time == 0L && T != huge_time && t != huge_time)) {
			if (t < T)
				{	/* test annotation is earliest */
				/* (1) If t is within the match window, and is a better match than
				the next test annotation, pair it. */
				if (T-t <= match_dt && T-t < abs(T-tprime))
					{
					pair(A, a);
					getref();
					gettest();
					}
			/* (2) There is no match to the test annotation, so pair it with a
	       pseudo-beat annotation and get the next one. */
				else
					{
					pair(rpann(t), a);
					gettest();
					}
				}
			else
				{		/* reference annotation is earliest */
				/* (3) If T is within the match window, and is a better match than
				the next reference annotation, pair it. */
				if (t-T <= match_dt && t-T < abs(t-Tprime)) {
					pair(A, a);
					gettest();
					getref();
					}
				/* (4) There is no match to the reference annotation, so pair it
				with a pseudo-beat annotation and get the next one. */
				else {
					pair(A, tpann(T));
					getref();
					}
				}
			}

		shut_down /= strtim("1");	/* convert from samples to seconds */

		/* Generate output. */
		print_results(fflag);
		NewPrintResults() ;

		wfdbquit();			/* close input files */
		}
	 exit(0);	/*NOTREACHED*/
	}
Beispiel #2
0
void genxcmp()
{
    int alen;
    static char mstring[550], *p, nullaux[1];

    if (ref_annot.anntyp == 0) getref();
    if (test_annot.anntyp == 0) gettest();
    if (!ref_annot.aux) ref_annot.aux = nullaux;
    if (!test_annot.aux) test_annot.aux = nullaux;
    while ((end_time > 0L && (T <= end_time || t <= end_time)) ||
	   (end_time == -1L && T != huge_time) ||
	   (end_time == 0L && T != huge_time && t != huge_time)) {
	for (p = mstring+1; p < mstring + *mstring; p++)
	    *p = '\0';
	if (t < T) {
	    /* Test annotation precedes reference annotation. */
	    if (T-t <= match_dt &&
		     (T-t < abs(T-tprime) || aprime == 'O')) {
		/* Annotation times match within the window. */
		if (test_annot.anntyp != ref_annot.anntyp ||
		    test_annot.subtyp != ref_annot.subtyp ||
		    test_annot.chan   != ref_annot.chan   ||
		    test_annot.num    != ref_annot.num    ||
		    strcmp(test_annot.aux, ref_annot.aux)) {
		    /* Annotation types, subtypes, ..., don't match. */
		    p = mstring+1;
		    (void)strcat(p, annstr(ref_annot.anntyp));
		    p += strlen(p);
		    if (test_annot.subtyp != ref_annot.subtyp ||
			test_annot.chan   != ref_annot.chan   ||
			test_annot.num    != ref_annot.num) {
			(void)sprintf(p, "[%d,%d,%d]", ref_annot.subtyp,
				ref_annot.chan, ref_annot.num);
			p += strlen(p);
		    }
		    if (*ref_annot.aux) {
			(void)sprintf(p, " (%s)", ref_annot.aux+1);
			p += strlen(p);
		    }
		    (void)sprintf(p, "/%s", annstr(test_annot.anntyp));
		    p += strlen(p);
		    if (*test_annot.aux)
			(void)sprintf(p, " (%s)", test_annot.aux+1);
		    alen = strlen(mstring+1);
		    if (alen > 254) {
			(void)fprintf(stderr,
				      "aux string truncated at %s (%ld)\n",
				timstr(test_annot.time), test_annot.time);
			alen = 254;
			mstring[alen+1] = '\0';
		    }
		    mstring[0] = alen;
		    test_annot.aux = mstring;
		    test_annot.anntyp = NOTE;
		}
		(void)putann(0, &test_annot);
		getref();
		gettest();
		if (!ref_annot.aux) ref_annot.aux = nullaux;
		if (!test_annot.aux) test_annot.aux = nullaux;
	    }
	    else {
		/* No matching reference annotation. */
		p = mstring+1;
		(void)sprintf(p, "%c/%s",
			   rpann(test_annot.time), annstr(test_annot.anntyp));
		p += strlen(p);
		if (*test_annot.aux)
		    (void)sprintf(p, " (%s)", test_annot.aux+1);
		alen = strlen(mstring+1);
		if (alen > 254) {
		    (void)fprintf(stderr, "aux string truncated at %s (%ld)\n",
			    timstr(test_annot.time), test_annot.time);
		    alen = 254;
		    mstring[alen+1] = '\0';
		}
		mstring[0] = alen;
		test_annot.aux = mstring;
		test_annot.anntyp = NOTE;
		(void)putann(0, &test_annot);
		gettest();
		if (!test_annot.aux) test_annot.aux = nullaux;
	    }
	}
	else {
	    /* Reference annotation precedes test annotation. */
	    if (t-T <= match_dt &&
		     (t-T < abs(t-Tprime) || Aprime == 'O')) {
		/* Annotation times match within the window. */
		if (test_annot.anntyp != ref_annot.anntyp ||
		    test_annot.subtyp != ref_annot.subtyp ||
		    test_annot.chan   != ref_annot.chan   ||
		    test_annot.num    != ref_annot.num    ||
		    strcmp(test_annot.aux, ref_annot.aux)) {
		    /* Annotation types, subtypes, ..., don't match. */
		    p = mstring+1;
		    (void)strcat(p, annstr(ref_annot.anntyp));
		    p += strlen(p);
		    if (test_annot.subtyp != ref_annot.subtyp ||
			test_annot.chan   != ref_annot.chan   ||
			test_annot.num    != ref_annot.num) {
			(void)sprintf(p, "[%d,%d,%d]", ref_annot.subtyp,
				ref_annot.chan, ref_annot.num);
			p += strlen(p);
		    }
		    if (*ref_annot.aux) {
			(void)sprintf(p, " (%s)", ref_annot.aux+1);
			p += strlen(p);
		    }
		    (void)sprintf(p, "/%s", annstr(test_annot.anntyp));
		    p += strlen(p);
		    if (*test_annot.aux)
			(void)sprintf(p, " (%s)", test_annot.aux+1);
		    alen = strlen(mstring+1);
		    if (alen > 254) {
			(void)fprintf(stderr,
				      "aux string truncated at %s (%ld)\n",
				timstr(test_annot.time), test_annot.time);
			alen = 254;
			mstring[alen+1] = '\0';
		    }
		    mstring[0] = alen;
		    test_annot.aux = mstring;
		    test_annot.anntyp = NOTE;
		}
		(void)putann(0, &test_annot);
		getref();
		gettest();
		if (!ref_annot.aux) ref_annot.aux = nullaux;
		if (!test_annot.aux) test_annot.aux = nullaux;
	    }
	    else {
		/* No matching test annotation. */
		p = mstring+1;
		(void)sprintf(p, "%s", annstr(ref_annot.anntyp));
		p += strlen(p);
		if (*ref_annot.aux) {
		    (void)sprintf(p, " (%s)", ref_annot.aux+1);
		    p += strlen(p);
		}
		(void)sprintf(p, "/%c", tpann(ref_annot.time));
		alen = strlen(mstring+1);
		if (alen > 254) {
		    (void)fprintf(stderr, "aux string truncated at %s (%ld)\n",
			    timstr(ref_annot.time), ref_annot.time);
		    alen = 254;
		    mstring[alen+1] = '\0';
		}
		mstring[0] = alen;
		ref_annot.aux = mstring;
		ref_annot.anntyp = NOTE;
		(void)putann(0, &ref_annot);
		getref();
		if (!ref_annot.aux) ref_annot.aux = nullaux;
	    }
	}
    }
}
Beispiel #3
0
int main(int argc, char **argv)
{
    int        me, nproc;
    int        c, all_ops = 1;
    int        T = 0, S = 0, P = 0;
    const int  DEFAULT_ITR = 7;
    int        iterations = DEFAULT_ITR;

    shmem_init();

    me = shmem_my_pe();
    nproc = shmem_n_pes();

    memset(target, -1, NUM_WRITE * sizeof(int));
    memset(source, -1, NUM_READ * sizeof(int));
    memset(sync_pes, -1, NUM_SYNC * sizeof(int));

    shmem_barrier_all();

    if (nproc != 2) {
        if (me == 0) {
            fprintf(stderr, "This is a micro test and is only "
                    "intended to run on exactly two processes you"
                    " are using %d\n", nproc);
        }
        shmem_finalize();
        return 0;
    }

    while ((c = getopt(argc, argv, "i:vdpgaAscfFh")) != -1) {
        switch (c) {
            case 'i':
                iterations = atoi(optarg);
                assert(iterations > 0);
                all_ops += 2;
                break;
            case 'v':
                verbose = 1;
                all_ops++;
                break;
            case 'd':
                debug = 1;
                break;
            case 'p':
                putfence(me, iterations, T++);
                break;
            case 'g':
                gettest(me, iterations, T++, S++, P++);
                break;
            case 'a':
                atomic_add(me, iterations, T++);
                break;
            case 'A':
                atomic_inc(me, iterations, T++);
                break;
            case 's':
                swaptest(me, iterations, T++, S++, P++);
                break;
            case 'c':
                cswaptest(me, iterations, T++, S++, P++);
                break;
            case 'f':
                fetchatomic_add(me, iterations, T++, S++);
                break;
            case 'F':
                fetchatomic_inc(me, iterations, T++, S++);
                break;
            case 'h':
            default:
                if (me == 0) {
                    fprintf(stderr, "input options:\n 1) single"
                            " argument option will run all tests by default"
                            "and additionally request:  -v (verbose) | "
                            "-i <number of interations>\n");
                    fprintf(stderr, " 2) two argument options "
                            "choose any combination of the following "
                            "to run individual tests:  -i <iterations>, -v"
                            ", -d, -p, -g, -a, -A, -s, -c, -f, -F, -h\n");
                }
                shmem_finalize();
                return 1;
        }
    }

    if (argc == all_ops || argc == 1) {
        putfence(me, iterations,  T++);
        gettest(me, iterations, T++, S++, P++);
        atomic_add(me, iterations, T++);
        atomic_inc(me, iterations, T++);
        swaptest(me, iterations, T++, S++, P++);
        cswaptest(me, iterations, T++, S++, P++);
        fetchatomic_add(me, iterations, T++, S++);
        fetchatomic_inc(me, iterations, T++, S++);
    }

    if (verbose) {
        if (me == 1)
            printf("PE 1: PASS: %8d iterations\n", iterations);
        else
            printf("PE 0 Successful exit\n");
    }

    shmem_finalize();

    return 0;
}