|
@@ -1,4 +1,4 @@
|
|
|
-/* A single test aimed at being looped with a script. Handles the number of Bytes passed in argv[1]. */
|
|
|
+/* A single,basic test aimed at being looped with a script. Handles the number of Bytes passed in argv[1]. */
|
|
|
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
@@ -23,16 +23,19 @@
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
{
|
|
|
+ /* output file */
|
|
|
FILE* fp = fopen("gpu-fpga.csv","a");
|
|
|
if( fp == NULL ){
|
|
|
printf("Cannot open file gpu-fpga.csv\n");
|
|
|
exit( EXIT_FAILURE );
|
|
|
}
|
|
|
|
|
|
+ /* each transfer deals 64 words of 4 bytes */
|
|
|
int nb_bytes = atoi(argv[argc -1]);
|
|
|
printf("nb_bytes = %d\n",nb_bytes);
|
|
|
- int nb_transfer = nb_bytes/(4*64); //each transfer deals 64 words of 4 bytes
|
|
|
-
|
|
|
+ int nb_transfer = nb_bytes/(4*64);
|
|
|
+
|
|
|
+ /* to be used to send only bytes of a certain DATA value */
|
|
|
unsigned char* data=(unsigned char*)calloc(nb_bytes,sizeof(*data));
|
|
|
memset(data,DATA,nb_bytes);
|
|
|
init_to_send(data,sizeof(char),nb_bytes);
|
|
@@ -97,8 +100,8 @@ int main(int argc, char* argv[])
|
|
|
exit( EXIT_FAILURE );
|
|
|
}
|
|
|
CUdeviceptr dBAR;
|
|
|
- /* assert_cu( cuMemHostRegister((void*)pciVa,128,CU_MEMHOSTREGISTER_IOMEMORY) ); */
|
|
|
- /* assert_cu( cuMemHostGetDevicePointer(&dBAR,(void*)pciVa, 0) ); */
|
|
|
+ assert_cu( cuMemHostRegister((void*)pciVa,128,CU_MEMHOSTREGISTER_IOMEMORY) );
|
|
|
+ assert_cu( cuMemHostGetDevicePointer(&dBAR,(void*)pciVa, 0) );
|
|
|
|
|
|
/* Config PCI for Pages*/
|
|
|
pcilib_kmem_handle_t* pciHandlePage;
|
|
@@ -141,20 +144,7 @@ int main(int argc, char* argv[])
|
|
|
|
|
|
double simple_write_meas1;
|
|
|
double simple_write_meas2;
|
|
|
- double start_meas;
|
|
|
double meas_result;
|
|
|
- unsigned char* getBack=(unsigned char*)calloc(nb_bytes,sizeof(*getBack));
|
|
|
-
|
|
|
- volatile uint64_t *hwaddr = (uint64_t*)((char*)gpuDescVa + DESCRIPTOR_OFFSET + 2 * sizeof(uint32_t));
|
|
|
-
|
|
|
- /* for(int j=0;j<nb_bytes;j++) */
|
|
|
- /* printf("%hhx",data[j]); */
|
|
|
- /* printf("\n"); */
|
|
|
- /* memcpy(getBack,(const void*)gpuPageVa,nb_bytes); */
|
|
|
- /* for(int j=0;j<nb_bytes;j++) */
|
|
|
- /* printf("%hhx",getBack[j]); */
|
|
|
- /* printf("\n"); */
|
|
|
-
|
|
|
|
|
|
printf("\nWorking on the FPGA\n");
|
|
|
WR32(REG_RESET_DMA, 1);
|
|
@@ -174,7 +164,6 @@ WR32_sleep(REG_PACKET_LENGTH,0x80000 | 64); // added flag
|
|
|
|
|
|
WR32_sleep(REG_INTERCONNECT, 0x232); //0x262);
|
|
|
WR32_sleep(REG_COUNTER,0x1);
|
|
|
- start_meas = 4. *RD32 (0x14)/ 1000;
|
|
|
*(int*)pciMemPtrDesc=0;
|
|
|
simple_write_meas1 = 4. *RD32 (0x14)/ 1000;
|
|
|
WR64(REG_DESCRIPTOR_ADDRESS,pageInfo.bus_addr);
|
|
@@ -184,28 +173,18 @@ WR32_sleep(REG_PACKET_LENGTH,0x80000 | 64); // added flag
|
|
|
|
|
|
usleep(1000);
|
|
|
|
|
|
- /* assert_cuda( cudaMemcpy((void*)gpuPageVa,(const void*)gpuPagePtr,nb_bytes,cudaMemcpyDeviceToHost) ); */
|
|
|
- /* /\* memcpy(getBack,(const void*)pciMemPtrDesc,nb_bytes); *\/ */
|
|
|
- /* memcpy(getBack,(const void*)gpuPageVa,nb_bytes); */
|
|
|
+ /* A few information for tests */
|
|
|
/* for(int j=0;j<nb_bytes;j++){ */
|
|
|
- /* /\* if( getBack[j]!=DATA ){ *\/ */
|
|
|
- /* /\* printf("Last at %d\n",j); *\/ */
|
|
|
- /* /\* goto exit; *\/ */
|
|
|
- /* /\* } *\/ */
|
|
|
- /* printf("%hhx",getBack[j]); */
|
|
|
+ /* printf("%hhx",((char*)gpuPageVa)[j]); */
|
|
|
/* } */
|
|
|
/* printf("\n"); */
|
|
|
/* printf("number of descriptor: %d\n",*(int*)pciMemPtrDesc); */
|
|
|
- /* printf("start_meas = %lf\n",start_meas); */
|
|
|
- /* printf("hwaddr = %p\ngpuPagePtr = %p\n",*hwaddr,pageInfo.bus_addr); */
|
|
|
|
|
|
fprintf(fp,"%lf",meas_result);
|
|
|
|
|
|
|
|
|
/* Close everything */
|
|
|
-exit:
|
|
|
printf("\nClosing the connections\n");
|
|
|
- free(getBack);
|
|
|
WR32(REG_COUNTER, 0);
|
|
|
WR32(REG_DMA, 0);
|
|
|
WR32(REG_RESET_DMA, 1);
|
|
@@ -215,7 +194,7 @@ exit:
|
|
|
|
|
|
pcilib_free_kernel_memory(pciCtx,pciHandleDesc,PCILIB_KMEM_FLAG_FORCE);
|
|
|
pcilib_free_kernel_memory(pciCtx,pciHandlePage,PCILIB_KMEM_FLAG_FORCE);
|
|
|
- /* assert_cu( cuMemHostUnregister((void*) pciVa) ); */
|
|
|
+ assert_cu( cuMemHostUnregister((void*) pciVa) );
|
|
|
pcilib_close(pciCtx);
|
|
|
assert_gdr( gdr_unmap(g,GPUMemHandlePage,gpuPageVa,nb_bytes) );
|
|
|
assert_gdr( gdr_unpin_buffer(g,GPUMemHandlePage) );
|