barrier_t *mppa_create_master_barrier (char *path_master, char *path_slave, int clusters) { int status, i; int ranks[clusters]; long long match; barrier_t *ret = (barrier_t*) malloc (sizeof (barrier_t)); ret->sync_fd_master = mppa_open(path_master, O_RDONLY); assert(ret->sync_fd_master != -1); ret->sync_fd_slave = mppa_open(path_slave, O_WRONLY); assert(ret->sync_fd_slave != -1); match = (long long) - (1 << clusters); status = mppa_ioctl(ret->sync_fd_master, MPPA_RX_SET_MATCH, match); assert(status == 0); for (i = 0; i < clusters; i++) ranks[i] = i; status = mppa_ioctl(ret->sync_fd_slave, MPPA_TX_SET_RX_RANKS, clusters, ranks); assert(status == 0); ret->mode = BARRIER_MASTER; return ret; }
portal_t *mppa_create_write_portal (char *path, void* buffer, unsigned long buffer_size, int receiver_rank) { portal_t *ret = (portal_t*) malloc (sizeof(portal_t)); ret->file_descriptor = mppa_open(path, O_WRONLY); assert(ret->file_descriptor != -1); // Tell mppa_io_write to wait for resources when sending a asynchronous message assert(mppa_ioctl(ret->file_descriptor, MPPA_TX_WAIT_RESOURCE_ON) == 0); // Select the DMA interface according to the receiver's rank. // This is only possible on the IO-node! if (__k1_get_cluster_id() == 128) assert(mppa_ioctl(ret->file_descriptor, MPPA_TX_SET_IFACE, receiver_rank % 4) == 0); // We need to initialize an aiocb for asynchronous writes. // It seems that the buffer and buffer size parameters are not important here, // because we're going to specify them with mppa_aiocb_set_pwrite() // before calling mppa_aio_write() assert(mppa_aiocb_ctor(&ret->aiocb, ret->file_descriptor, buffer, buffer_size) == &ret->aiocb); return ret; }
barrier_t *mppa_create_slave_barrier (char *path_master, char *path_slave) { int status; barrier_t *ret = (barrier_t*) malloc (sizeof (barrier_t)); ret->sync_fd_master = mppa_open(path_master, O_WRONLY); assert(ret->sync_fd_master != -1); ret->sync_fd_slave = mppa_open(path_slave, O_RDONLY); assert(ret->sync_fd_slave != -1); long long match; status = mppa_ioctl(ret->sync_fd_slave, MPPA_RX_SET_MATCH, (long long) 0); //pq long long 0? assert(status == 0); ret->mode = BARRIER_SLAVE; return ret; }
/* * Open NoC connectors. */ void open_noc_connectors(void) { int i; /* Loop index. */ char path[35]; /* Connector path. */ uint64_t match; /* match value. */ match = -(1 << nclusters); assert((sync_fd = mppa_open("/mppa/sync/128:64", O_RDONLY)) != -1) ; assert(mppa_ioctl(sync_fd, MPPA_RX_SET_MATCH, match) != -1); /* Open channels. */ for (i = 0; i < nclusters; i++) { sprintf(path, "/mppa/channel/%d:%d/128:%d", i, i + 1, i + 1); outfd[i] = mppa_open(path, O_WRONLY); assert(outfd[i] != -1); sprintf(path, "/mppa/channel/128:%d/%d:%d", i + 17, i, i + 17); infd[i] = mppa_open(path, O_RDONLY); assert(outfd[i] != -1); } }