Exemple #1
0
void use_text(const text_data *t)
{
	if(t!=NULL)
	{
		use_buf(t->v);
		glVertexAttribPointer(2,3,GL_FLOAT,GL_FALSE,0,NULL);
		glVertexAttribDivisor(2,1); /* needed here every time? */
	}

	_active_text=(text_data*)t;
}
Exemple #2
0
int cfio_recv_add_msg(int client_rank, int size, char *data, uint32_t *func_code, int itr)
{
    int client_index;
    cfio_msg_t *msg;

    client_index = cfio_map_get_client_index_of_server(client_rank);

    if (cfio_buf_is_empty(buffer[client_index])) {
        cfio_buf_clear(buffer[client_index]);
    }

    if(is_free_space_enough(buffer[client_index], size)
            == CFIO_BUF_FREE_SPACE_NOT_ENOUGH) {
#ifdef DEBUG
        //	printf("%s server %d client %d CFIO_RECV_BUF_FULL \n", __func__, rank, client_index);
        printf("itr %d server %d client %d buffer_info: start, used, free: %lu, %lu, %lu .\n", 
                itr, rank, client_rank, (uintptr_t)(buffer[client_index]->start_addr),
                (uintptr_t)(buffer[client_index]->used_addr),
                (uintptr_t)(buffer[client_index]->free_addr));
#endif
        return CFIO_RECV_BUF_FULL;
    }

    *func_code = *((uint32_t *)(data + sizeof(size_t)));

#ifdef DEBUG
    printf("itr %d server %d client %d func_code %d msg_size %d \n", itr, rank, client_rank, *func_code, size);
#endif

    if (!size) {
#ifdef DEBUG
        printf("itr %d server %d client %d buffer_info: start, used, free: %lu, %lu, %lu .\n", 
                itr, rank, client_rank, (uintptr_t)(buffer[client_index]->start_addr),
                (uintptr_t)(buffer[client_index]->used_addr),
                (uintptr_t)(buffer[client_index]->free_addr));
#endif
        return CFIO_ERROR_UNEXPECTED_MSG;
    }

    if (FUNC_FINAL == *func_code) {
        //	printf("%s server %d client %d FUNC_FINAL %d \n", __func__, rank, client_index, FUNC_FINAL);
        return CFIO_ERROR_NONE;
    } else if (FUNC_NC_CLOSE == *func_code) {
#ifdef DEBUG
        printf("itr %d server %d client %d buffer_info: start, end, used, free: %lu, %lu, %lu, %lu .\n", 
                itr, rank, client_rank, 
                (uintptr_t)(buffer[client_index]->start_addr),
                (uintptr_t)(buffer[client_index]->start_addr + buffer[client_index]->size),
                (uintptr_t)(buffer[client_index]->used_addr),
                (uintptr_t)(buffer[client_index]->free_addr));
#endif
    }

    memcpy(buffer[client_index]->free_addr, data, size);

    msg = cfio_msg_create();
    msg->addr = buffer[client_index]->free_addr;
    msg->size = size;
    msg->src = client_rank;
    msg->dst = rank;
    msg->func_code = *func_code; 

    use_buf(buffer[client_index], size);
    qlist_add_tail(&(msg->link), &(msg_head[client_index].link));

    return CFIO_ERROR_NONE;
}
Exemple #3
0
Fichier : recv.c Projet : CFIO/CFIO
int cfio_recv(
	int src, int rank, MPI_Comm comm, uint32_t *func_code)
{
    MPI_Status status;
    int size;
    cfio_msg_t *msg;
    int client_index;

    client_index = cfio_map_get_client_index_of_server(src);
    //times_start();
    debug(DEBUG_RECV, "client_index = %d", client_index);
    if(is_free_space_enough(buffer[client_index], max_msg_size)
	    == CFIO_BUF_FREE_SPACE_NOT_ENOUGH)
    {
	return CFIO_RECV_BUF_FULL;
    }
//    ensure_free_space(buffer[client_index], max_msg_size, 
//	    cfio_recv_server_buf_free);

    MPI_Recv(buffer[client_index]->free_addr, max_msg_size, MPI_BYTE, src,  
	    MPI_ANY_TAG, comm, &status);
    MPI_Get_count(&status, MPI_BYTE, &size);
    debug(DEBUG_RECV, "recv: size = %d", size);
    //total_size += size;
    //if(min_size == 0 || min_size > size)
    //{
    //    min_size = size;
    //}
    //if(max_size == 0 || max_size < size)
    //{
    //    max_size = size;
    //}

    //printf("proc %d , recv: size = %d, from %d\n",rank, size, src);
    //debug(DEBUG_RECV, "code = %u", *((uint32_t *)buffer->free_addr));

    if(status.MPI_SOURCE != status.MPI_TAG)
    {
	return CFIO_ERROR_MPI_RECV;
    }

    msg = cfio_msg_create();
    msg->addr = buffer[client_index]->free_addr;
    msg->size = size;
    msg->src = status.MPI_SOURCE;
    msg->dst = rank;
    // get the func_code but not unpack it
    msg->func_code = *((uint32_t*)(msg->addr + sizeof(size_t))); 
    *func_code = msg->func_code;
    debug(DEBUG_RECV, "func_code = %u", *func_code);

#ifndef SVR_RECV_ONLY
    use_buf(buffer[client_index], size);
#endif
    
    /* need lock */
    if((*func_code) != FUNC_IO_END)
    {
#ifndef SVR_RECV_ONLY
	qlist_add_tail(&(msg->link), &(msg_head[client_index].link));
#endif
    }
    
    //debug(DEBUG_RECV, "uesd_size = %lu", used_buf_size(buffer));
    debug(DEBUG_RECV, "success return");
    
    return CFIO_ERROR_NONE;
}