Ejemplo n.º 1
0
void mppa_barrier_wait(barrier_t *barrier) {
	int status;
	long long dummy;

	if(barrier->mode == BARRIER_MASTER) {
		dummy = -1;
		long long match;

		status = mppa_read(barrier->sync_fd_master, &match, sizeof(match));
		assert(status == sizeof(match));
		
		status = mppa_write(barrier->sync_fd_slave, &dummy, sizeof(long long));
		assert(status == sizeof(long long));
	}
	else {
		dummy = 0;
		long long mask;

		mask = 0;
		mask |= 1 << __k1_get_cluster_id();

		status = mppa_write(barrier->sync_fd_master, &mask, sizeof(mask));
		assert(status == sizeof(mask));
		
		status = mppa_read(barrier->sync_fd_slave, &dummy, sizeof(long long));
		assert(status == sizeof(long long));
	}
}
Ejemplo n.º 2
0
/*
 * Synchronizes status.
 */
static void sync_status(void)
{
	ssize_t n;
	ssize_t count;
	
	n = NUM_THREADS*sizeof(int);
	count = mppa_write(outfd, &has_changed[rank*NUM_THREADS], n);
	assert(n == count);
	count = mppa_write(outfd, &too_far[rank*NUM_THREADS], n);
	assert(n == count);
		
	n = nprocs*NUM_THREADS*sizeof(int);
	count = mppa_read(infd, has_changed, n);
	assert(n == count);
	count = mppa_read(infd, too_far, n);
	assert(n == count);
}
Ejemplo n.º 3
0
/*
 * Synchronizes centroids.
 */
static void sync_centroids(void)
{
	ssize_t n;     /* Bytes to send/receive.        */
	ssize_t count; /* Bytes actually sent/received. */
	
	n = lncentroids[rank]*dimension*sizeof(float);
	count = mppa_write(outfd, lcentroids, n);
	assert(n == count);
	
	n = ncentroids*dimension*sizeof(float);
	count = mppa_read(infd, centroids, n);
	assert(n == count);
}
Ejemplo n.º 4
0
/*
 * Receives work from master process.
 */
static void getwork(void)
{	
	int i;
	
	ssize_t n;     /* Bytes to send/receive.        */
	ssize_t count; /* Bytes actually sent/received. */
	
	timer_init();
	
	n = sizeof(int);
	count = mppa_read(infd, &lnpoints, n);
	assert(n == count);
	
	data_receive(infd, &nprocs, sizeof(int));
	
	data_receive(infd, &ncentroids, sizeof(int));
	
	data_receive(infd, &mindistance, sizeof(int));
	
	data_receive(infd, &dimension, sizeof(int));
	
	n = nprocs*sizeof(int);
	count = mppa_read(infd, lncentroids, n);
	assert(count != -1);
	
	n = dimension*sizeof(float);
	for (i = 0; i < lnpoints; i++)
		data_receive(infd, &points[i*dimension], n);
	
	n = ncentroids*dimension*sizeof(float);
	count = mppa_read(infd, centroids, n);
	assert(n == count);
	
	n = lnpoints*sizeof(int);
	count = mppa_read(infd, map, n);
	assert(n == count);
}
Ejemplo n.º 5
0
/*
 * Synchronizes partial population.
 */
static void sync_ppopulation(void)
{
	ssize_t n;     /* Bytes to send/receive.        */
	ssize_t count; /* Bytes actually sent/received. */
		
	/* Send partial population. */
	n = ncentroids*sizeof(int);
	count = mppa_write(outfd, ppopulation, n);
	assert(n == count);
	
	/* Receive partial population. */
	n = nprocs*lncentroids[rank]*sizeof(int);
	count = mppa_read(infd, ppopulation, n);
	assert(n == count);
}
Ejemplo n.º 6
0
void mppa_read_rqueue (rqueue_t *rqueue, void *buffer, int buffer_size) {
	int status;
	status = mppa_read(rqueue->file_descriptor, buffer, buffer_size);
	assert(status == buffer_size);
}
Ejemplo n.º 7
0
void mppa_read_channel (channel_t *channel, void *buffer, int buffer_size) {
	int status= mppa_read(channel->file_descriptor, buffer, buffer_size);
	assert(status == buffer_size);
}
Ejemplo n.º 8
0
/*
 * Waits for slaves to be ready.
 */
void sync_slaves(void)
{
	uint64_t match;

	assert(mppa_read(sync_fd, &match, 8) == 8);
}