Esempio n. 1
0
void *test(void *data)
{
    int rand_max;
    thread_data_t *d = (thread_data_t *)data;
    uint64_t res;
    phys_id= the_cores[d->id];
    set_cpu(phys_id);

    seeds = seed_rand();
    rand_max = num_entries - 1;

    /* Init of local data if necessary */

    /* Wait on barrier */
    barrier_cross(d->barrier);
    int entry;

    while (stop == 0) {
        if (num_entries==1) {
            entry=0;
        } else {
            entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max;
        }
        //   entry = (int)(erand48(seed) * rand_max) + rand_min;
#ifdef TEST_CAS
        do {
            res = CAS_U8(&(the_data[entry].data),0,1);
        } while(res!=0);
#elif defined(TEST_TAS)
        do {
            res = TAS_U8(&(the_data[entry].data));
        } while (res!=0);
#elif defined(TEST_FAI)
        FAI_U8(&(the_data[entry].data));
#else
        perror("No test primitive specified");
#endif 
        MEM_BARRIER;
        the_data[entry].data = 0;
        d->num_operations++;
        if (op_pause>0) {
            cpause(op_pause);
        }
    }

    /* Free any local data if necessary */ 

    return NULL;
}
Esempio n. 2
0
// Match closing fences against their partners, and if on screen, briefly light the cursor there.
int fmatch(int ch) {
	Dot odot;		// Original line pointer and offset.
	Line *toplp;		// Top line in current window.
	int count;		// Current fence level count.
	int opench;		// Open fence.
	int c;			// Current character in scan.
	WindFace *wfp = &curwp->w_face;

	// Skip this if executing a script or a keyboard macro.
	if((opflags & OPSCRIPT) || kmacro.km_state == KMPLAY)
		return rc.status;

	// First get the display update out there.
	if(update(false) != SUCCESS)
		return rc.status;

	// Save the original cursor position.
	odot = wfp->wf_dot;

	// Set up proper open fence for passed close fence.
	switch(ch) {
		case ')':
			opench = '(';
			break;
		case '}':
			opench = '{';
			break;
		default:	// ']'
			opench = '[';
		}

	// Get top line of window and set up for scan.
	toplp = lback(wfp->wf_toplnp);
	count = 1;
	(void) backch(1);

	// Scan back until we find it, or move past the top of the window.
	while(count > 0 && wfp->wf_dot.lnp != toplp) {
		(void) backch(1);
		if(wfp->wf_dot.off == lused(wfp->wf_dot.lnp))
			c = '\n';
		else
			c = lgetc(wfp->wf_dot.lnp,wfp->wf_dot.off);
		if(c == ch)
			++count;
		else if(c == opench)
			--count;
		if(wfp->wf_dot.lnp == lforw(curbp->b_hdrlnp) && wfp->wf_dot.off == 0)
			break;
		}

	// If count is zero, we have a match -- display the sucker.
	if(count == 0) {
		if(update(false) != SUCCESS)
			return rc.status;
		cpause(fencepause);
		}

	// Restore the previous position.
	wfp->wf_dot = odot;

	return rc.status;
	}
Esempio n. 3
0
void *test_latency(void *data)
{
    thread_data_t *d = (thread_data_t *)data;
#ifndef NO_SET_CPU
  int phys_id = the_cores[d->id];
  set_cpu(phys_id);
#endif
    int rand_max;
#if defined(TEST_CTR)
    data_type old_data;
    data_type new_data;
#endif
    volatile uint64_t res;

    seeds = seed_rand();
    rand_max = num_entries - 1;

    unsigned long do_not_measure=0;
    int entry=0;
    ticks t1 = 0, t2 = 0;
    barrier_cross(d->barrier);

    while (stop == 0) {
        if (num_entries>1) {
            entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max;
        }
        do_not_measure=(d->num_operations) & 0x1f; 
#ifdef TEST_CAS
        if ((d->num_operations)&1) { 
            res = CAS_U8(&(the_data[entry].data),1,0);
        } else {
            if (!do_not_measure) {
                t1=getticks();
#  ifdef __tile__
                MEM_BARRIER;
#  endif
                res = CAS_U8(&(the_data[entry].data),0,1);
#  ifdef __tile__
                MEM_BARRIER;
#  endif
                t2=getticks();

            } else {
                res = CAS_U8(&(the_data[entry].data),0,1);
            }
        }
#elif defined(TEST_SWAP)
        if ((d->num_operations)&1) {
            res = SWAP_U8(&(the_data[entry].data),0);
        } else {
            if (do_not_measure) {
                res = SWAP_U8(&(the_data[entry].data),1);
            } else {
                t1=getticks(); 
#  ifdef __tile__
                MEM_BARRIER;
#  endif
               res = SWAP_U8(&(the_data[entry].data),1);
#  ifdef __tile__
                MEM_BARRIER;
#  endif

                t2=getticks();
            }
        }
#elif defined(TEST_CTR)
        if (do_not_measure) {
            do {
                old_data=the_data[entry].data;
                new_data=old_data+1;
            } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data);
        } else {
            t1=getticks();
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            do {
                old_data=the_data[entry].data;
                new_data=old_data+1;
            } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data);
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            t2=getticks();
        }
#elif defined(TEST_TAS)
        if (do_not_measure) {
            res = TAS_U8(&(the_data[entry].data));
        } else {
            t1=getticks();
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            res = TAS_U8(&(the_data[entry].data));
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            t2=getticks();
        }
        if (res==0) {
            the_data[entry].data = 0;
        }
#elif defined(TEST_FAI)
        if (do_not_measure) {
            FAI_U8(&(the_data[entry].data));
        } else {
            t1=getticks();
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            FAI_U8(&(the_data[entry].data));
#  ifdef __tile__
                MEM_BARRIER;
#  endif
            t2=getticks();
        }
#else
        perror("No test primitive specified");
#endif 
        if (!do_not_measure) {
            d->num_measured++;
            d->total_time+=t2-t1-correction;
        }
        d->num_operations++;
        if (op_pause>0) {
            cpause(op_pause);
        }
    }
    
     /* avoid warning of unused var*/
    if (res == 12345654)
      {
	printf("%d", (int) res);
      }

    return NULL;
}
Esempio n. 4
0
void *test_throughput(void *data)
{
    thread_data_t *d = (thread_data_t *)data;
#ifndef NO_SET_CPU
  int phys_id = the_cores[d->id];
  set_cpu(phys_id);
#endif
    int rand_max;
#if defined(TEST_CTR)
    data_type old_data;
    data_type new_data;
#endif
    volatile uint64_t res;

    seeds = seed_rand();
    rand_max = num_entries - 1;

    barrier_cross(d->barrier);
    int entry=0;
    while (stop == 0) {
        if (num_entries>1) {
            entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max;
        }
#ifdef TEST_CAS
        if ((d->num_operations)&1) {
            res = CAS_U8(&(the_data[entry].data),1,0);
        } else {
            res = CAS_U8(&(the_data[entry].data),0,1);
        }
#elif defined(TEST_SWAP)
#  ifdef __sparc__
        if ((d->num_operations)&1) {
            res = SWAP_U32(&(the_data[entry].data),0);
        } else {
            res = SWAP_U32(&(the_data[entry].data),1);
        }

#  else
        if ((d->num_operations)&1) {
            res = SWAP_U8(&(the_data[entry].data),0);
        } else {
            res = SWAP_U8(&(the_data[entry].data),1);
        }
#  endif
#elif defined(TEST_CTR)
        do {
            old_data=the_data[entry].data;
            new_data=old_data+1;
        } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data);
#elif defined(TEST_TAS)
        res = TAS_U8(&(the_data[entry].data));
        if (res==0) {
            the_data[entry].data = 0;
        }
#elif defined(TEST_FAI)
        FAI_U8(&(the_data[entry].data));
#else
        perror("No test primitive specified");
#endif 
        d->num_operations++;
        if (op_pause>0) {
            cpause(op_pause);
        }
    }

     /* avoid warning of unused var*/
    if (res == 12345654)
      {
	printf("%d", (int) res);
      }

    return NULL;
}
Esempio n. 5
0
void *test(void *data)
{
    thread_data_t *d = (thread_data_t *)data;
    phys_id = the_cores[d->id];
    set_cpu(phys_id);
    int rand_max;
    data_type old_data;
    data_type new_data;
    uint64_t res;

    seeds = seed_rand();
    rand_max = num_entries - 1;

    /* Init of local data if necessary */
    unsigned long do_not_measure=0;
    int entry;
    ticks t1,t2;
    /* Wait on barrier */
    barrier_cross(d->barrier);

    while (stop == 0) {
        if (num_entries==1) {
            entry=0;
        } else {
            entry =(int) my_random(&(seeds[0]),&(seeds[1]),&(seeds[2])) & rand_max;
        }
        do_not_measure=(d->num_operations) & 0x1f; 
        //   entry = (int)(erand48(seed) * rand_max) + rand_min;
#ifdef TEST_CAS
        //    do {
        if ((d->num_operations)&1) { 
            res = CAS_U8(&(the_data[entry].data),1,0);
        } else {
            if (!do_not_measure) {
                t1=getticks();
                res = CAS_U8(&(the_data[entry].data),0,1);
                t2=getticks();

            } else {
                res = CAS_U8(&(the_data[entry].data),0,1);
            }
        }
        //    MEM_BARRIER;
        //    } while(res!=0);
#elif defined(TEST_SWAP)
        //    do {
        if ((d->num_operations)&1) {
            res = SWAP_U8(&(the_data[entry].data),0);
        } else {
            if (do_not_measure) {
                res = SWAP_U8(&(the_data[entry].data),1);
            } else {
                t1=getticks(); 
                res = SWAP_U8(&(the_data[entry].data),1);
                t2=getticks();
            }
        }
        //MEM_BARRIER;
        //    } while(res!=0);
#elif defined(TEST_CTR)
        if (do_not_measure) {
            do {
                old_data=the_data[entry].data;
                new_data=old_data+1;
            } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data);
        } else {
            t1=getticks();
            do {
                old_data=the_data[entry].data;
                new_data=old_data+1;
            } while (CAS_U8(&(the_data[entry].data),old_data,new_data)!=old_data);
            t2=getticks();

        }
        // MEM_BARRIER;
#elif defined(TEST_TAS)
        //    do {
        if (do_not_measure) {
            res = TAS_U8(&(the_data[entry].data));
        } else {
            t1=getticks();
            res = TAS_U8(&(the_data[entry].data));
            t2=getticks();
        }
        if (res==0) {
            //            MEM_BARRIER;
            the_data[entry].data = 0;
        }

        //    } while (res!=0);
#elif defined(TEST_FAI)
        if (do_not_measure) {
            FAI_U8(&(the_data[entry].data));
        } else {
            t1=getticks();
            FAI_U8(&(the_data[entry].data));
            t2=getticks();
        }
        //        MEM_BARRIER;
#else
        perror("No test primitive specified");
#endif 
        //#ifdef XEON
        //MEM_BARRIER;
        //__sync_synchronize();
        //#endif
        if (!do_not_measure) {
            d->num_measured++;
            d->total_time+=t2-t1-correction;
        }
        d->num_operations++;
        if (op_pause>0) {
            cpause(op_pause);
            //cdelay(op_pause);
        }
    }

    /* Free any local data if necessary */ 

    return NULL;
}