client/src/unifycr.c
static int unifycr_init_recv_shm(int local_rank_idx, int app_id) {
	int rc = -1;

    char *env = getenv("SHM_RECV_SIZE");
	if (env) {
		shm_recv_size = atol(env);
	}

	char shm_name[GEN_STR_LEN] = {0};
	sprintf(shm_name, "%d-recv-%d", app_id, local_rank_idx);

	recvbuf_fd = shm_open(shm_name, MMAP_OPEN_FLAG, MMAP_OPEN_MODE);
	if(-1 == (rc = recvbuf_fd))
	{
		return UNIFYCR_FAILURE;
	}

	rc = ftruncate(recvbuf_fd, shm_recv_size);
	if(-1 == rc)
	{
		return UNIFYCR_FAILURE;
	}

	shm_recvbuf = mmap(NULL, shm_recv_size, PROT_WRITE|PROT_READ,\
			MAP_SHARED, recvbuf_fd, SEEK_SET);
	if(NULL == shm_recvbuf)
	{
		return UNIFYCR_FAILURE;
	}

	*((int *)shm_recvbuf) = app_id + 3;
	return 0;
}
/**
* Initialize the shared recv memory buffer
* to receive data from the delegators
*/
Initialize the shared recv memory buffer
to receive data from the delegators
Initialize the shared recv memory buffer to receive data from the delegators
static int unifycr_init_recv_shm(int local_rank_idx, int app_id) {
	int rc = -1;
    char *env = getenv("SHM_RECV_SIZE");
	if (env) {
		shm_recv_size = atol(env);
	}
	char shm_name[GEN_STR_LEN] = {0};
	sprintf(shm_name, "%d-recv-%d", app_id, local_rank_idx);
	recvbuf_fd = shm_open(shm_name, MMAP_OPEN_FLAG, MMAP_OPEN_MODE);
	if(-1 == (rc = recvbuf_fd))
	{
		return UNIFYCR_FAILURE;
	}
	rc = ftruncate(recvbuf_fd, shm_recv_size);
	if(-1 == rc)
	{
		return UNIFYCR_FAILURE;
	}
	shm_recvbuf = mmap(NULL, shm_recv_size, PROT_WRITE|PROT_READ,\
			MAP_SHARED, recvbuf_fd, SEEK_SET);
	if(NULL == shm_recvbuf)
	{
		return UNIFYCR_FAILURE;
	}
	*((int *)shm_recvbuf) = app_id + 3;
	return 0;
}
static int unifycr_init_recv_shm ( int local_rank_idx , int app_id ) { int rc = -1 ; char * env = getenv ( " " ) ; if ( env ) { shm_recv_size = atol ( env ) ; } char shm_name [ GEN_STR_LEN ] = { 0 } ; sprintf ( shm_name , " " , app_id , local_rank_idx ) ; recvbuf_fd = shm_open ( shm_name , MMAP_OPEN_FLAG , MMAP_OPEN_MODE ) ; if ( -1 == ( rc = recvbuf_fd ) ) { return UNIFYCR_FAILURE ; } rc = ftruncate ( recvbuf_fd , shm_recv_size ) ; if ( -1 == rc ) { return UNIFYCR_FAILURE ; } shm_recvbuf = mmap ( NULL , shm_recv_size , PROT_WRITE | PROT_READ , MAP_SHARED , recvbuf_fd , SEEK_SET ) ; if ( NULL == shm_recvbuf ) { return UNIFYCR_FAILURE ; } * ( ( int * ) shm_recvbuf ) = app_id + 3 ; return 0 ; }
Initialize the shared recv memory buffer
to receive data from the delegators
Initialize the shared recv memory buffer to receive data from the delegators