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

	/* initialize request buffer size*/
	char *env = getenv("SHM_REQ_SIZE");
	if (env) {
		shm_req_size = atol(env);
	}

	char shm_name[GEN_STR_LEN] = {0};
	sprintf(shm_name, "%d-req-%d", app_id, local_rank_idx);
	reqbuf_fd = shm_open(shm_name, MMAP_OPEN_FLAG, MMAP_OPEN_MODE);
	if(-1 == (rc = reqbuf_fd))
	{
		return UNIFYCR_FAILURE;
	}

	rc = ftruncate(reqbuf_fd, shm_req_size);
	if(-1 == rc)
	{
		return UNIFYCR_FAILURE;
	}


	shm_reqbuf = mmap(NULL, shm_req_size, PROT_WRITE|PROT_READ,\
			MAP_SHARED, reqbuf_fd, SEEK_SET);
	if(NULL == shm_reqbuf)
	{
		return UNIFYCR_FAILURE;
	}

	return 0;
}
/**
* Initialize the shared request memory, which
* is used to buffer the list of read requests
* to be transferred to the delegator on the
* server side.
* @param local_rank_idx: local process id
* @param app_id: which application this
*  process is from
* @return success/error code
*/
Initialize the shared request memory, which
is used to buffer the list of read requests
to be transferred to the delegator on the
server side.
Initialize the shared request memory which is used to buffer the list of read requests to be transferred to the delegator on the server side .
static int unifycr_init_req_shm(int local_rank_idx, int app_id) {
	int rc = -1;
	char *env = getenv("SHM_REQ_SIZE");
	if (env) {
		shm_req_size = atol(env);
	}
	char shm_name[GEN_STR_LEN] = {0};
	sprintf(shm_name, "%d-req-%d", app_id, local_rank_idx);
	reqbuf_fd = shm_open(shm_name, MMAP_OPEN_FLAG, MMAP_OPEN_MODE);
	if(-1 == (rc = reqbuf_fd))
	{
		return UNIFYCR_FAILURE;
	}
	rc = ftruncate(reqbuf_fd, shm_req_size);
	if(-1 == rc)
	{
		return UNIFYCR_FAILURE;
	}
	shm_reqbuf = mmap(NULL, shm_req_size, PROT_WRITE|PROT_READ,\
			MAP_SHARED, reqbuf_fd, SEEK_SET);
	if(NULL == shm_reqbuf)
	{
		return UNIFYCR_FAILURE;
	}
	return 0;
}
static int unifycr_init_req_shm ( int local_rank_idx , int app_id ) { int rc = -1 ; char * env = getenv ( " " ) ; if ( env ) { shm_req_size = atol ( env ) ; } char shm_name [ GEN_STR_LEN ] = { 0 } ; sprintf ( shm_name , " " , app_id , local_rank_idx ) ; reqbuf_fd = shm_open ( shm_name , MMAP_OPEN_FLAG , MMAP_OPEN_MODE ) ; if ( -1 == ( rc = reqbuf_fd ) ) { return UNIFYCR_FAILURE ; } rc = ftruncate ( reqbuf_fd , shm_req_size ) ; if ( -1 == rc ) { return UNIFYCR_FAILURE ; } shm_reqbuf = mmap ( NULL , shm_req_size , PROT_WRITE | PROT_READ , MAP_SHARED , reqbuf_fd , SEEK_SET ) ; if ( NULL == shm_reqbuf ) { return UNIFYCR_FAILURE ; } return 0 ; }
Initialize the shared request memory, which
is used to buffer the list of read requests
to be transferred to the delegator on the
server side.
Initialize the shared request memory which is used to buffer the list of read requests to be transferred to the delegator on the server side .
/* initialize request buffer size*/