extern "C"{ #include "structures.h" #include "lib_snake_2_gpu.h" } #include "stdio.h" void snake2gpu( snake_node_gpu * d_snake, snake_node* h_snake, int n ){ snake_node * snake = h_snake; snake_node_gpu snake_nodes[n]; for (int i=0; icontrib.sum_1 ; snake_nodes[i].sum_x = snake->contrib.sum_x ; snake_nodes[i].sum_x2 = snake->contrib.sum_x2 ; snake_nodes[i].code_segment = snake->code_segment ; snake_nodes[i].freeman_in = snake->freeman_in ; snake_nodes[i].freeman_out = snake->freeman_out ; snake_nodes[i].nb_pixels = snake->nb_pixels ; snake_nodes[i].posi = snake->posi ; snake_nodes[i].posj = snake->posj ; snake_nodes[i].centre_i = snake->centre_i ; snake_nodes[i].centre_j = snake->centre_j ; snake_nodes[i].last_move = snake->last_move ; snake = snake->noeud_suiv ; } cudaMemcpy( d_snake, snake_nodes, n*sizeof(snake_node_gpu), cudaMemcpyHostToDevice ); /*verif integrite data*/ /* snake_node_gpu new_snake_nodes[n]; cudaMemcpy( new_snake_nodes , d_snake, n*sizeof(snake_node_gpu), cudaMemcpyDeviceToHost ); for (int i=0; inoeud_suiv = snake; snake->noeud_prec = snake_prec; } if (i == n-1) { snake->noeud_suiv = *h_snake; (*h_snake)->noeud_prec = snake; } /* snake->contrib.sum_1 = snake_nodes[i].sum_1 ; snake->contrib.sum_x = snake_nodes[i].sum_x ; snake->contrib.sum_x2 = snake_nodes[i].sum_x2 ; snake->code_segment = snake_nodes[i].code_segment ; snake->freeman_in = snake_nodes[i].freeman_in ; snake->freeman_out = snake_nodes[i].freeman_out ; */ snake->nb_pixels = snake_nodes[i].nb_pixels ; snake->posi = snake_nodes[i].posi ; snake->posj = snake_nodes[i].posj ; /* snake->centre_i = snake_nodes[i].centre_i ; snake->centre_j = snake_nodes[i].centre_j ; snake->last_move = snake_nodes[i].last_move ; */ } /*verif integrite donnees*/ snake = *h_snake ; for (int i=0; icode_segment ) ; printf("\tfreeman_in : %d\n", snake->freeman_in ); printf("\tfreeman_out : %d\n", snake->freeman_out ) ; */ printf("\tnb_pixels : %d", snake->nb_pixels ) ; printf("\ti = %d ", snake->posi ) ; printf("\tj = %d \n", snake->posj ) ; /* printf("\tcentre i = %d\n", snake->centre_i ) ; printf("\tcentre j = %d\n", snake->centre_j ) ; printf("\tcontribs = %lu - %lu - %lu\n", snake->contrib.sum_1, snake->contrib.sum_x, snake->contrib.sum_x2 ) ; printf("\tlast_move : %d\n", snake->last_move ) ; */ snake = snake->noeud_suiv; } delete snake_nodes; }