|
@@ -43,7 +43,7 @@ int main()
|
|
|
assert_cu( cuCtxGetDevice(&GPU) );
|
|
|
printf("Device for this context: %d\n",GPU);
|
|
|
CUcontext cuCtx;
|
|
|
- assert_cu( cuCtxCreate(&cuCtx,0,GPU) );
|
|
|
+ assert_cu( cuCtxCreate(&cuCtx,CU_CTX_MAP_HOST,GPU) );
|
|
|
assert_cu( cuCtxGetDevice(&GPU) );
|
|
|
printf("Device for this context: %d\n",GPU);
|
|
|
int pi;
|
|
@@ -98,7 +98,7 @@ int main()
|
|
|
|
|
|
/* Config PCI for Pages*/
|
|
|
pcilib_kmem_handle_t* pciHandlePage;
|
|
|
- pciHandlePage = pcilib_alloc_kernel_memory(pciCtx,PCILIB_KMEM_TYPE_CONSISTENT,1,64,4096,PCILIB_KMEM_USE_STANDARD,PCILIB_KMEM_FLAG_REUSE);
|
|
|
+ pciHandlePage = pcilib_alloc_kernel_memory(pciCtx,PCILIB_KMEM_TYPE_DMA_C2S_PAGE,1,PAGE_SIZE,4096,PCILIB_KMEM_USE_DMA_PAGES,(pcilib_kmem_flags_t)(PCILIB_KMEM_FLAG_EXCLUSIVE|PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_HARDWARE));
|
|
|
if( pciHandlePage == NULL )
|
|
|
{
|
|
|
printf("Cannot allocate PCI kernel memory\n");
|
|
@@ -123,7 +123,7 @@ int main()
|
|
|
|
|
|
/* Config PCI for Desc */
|
|
|
pcilib_kmem_handle_t* pciHandleDesc;
|
|
|
- pciHandleDesc = pcilib_alloc_kernel_memory(pciCtx,PCILIB_KMEM_TYPE_CONSISTENT,1,64,4096,PCILIB_KMEM_USE_STANDARD,PCILIB_KMEM_FLAG_REUSE);
|
|
|
+ pciHandleDesc = pcilib_alloc_kernel_memory(pciCtx,PCILIB_KMEM_TYPE_CONSISTENT,1,128,4096,PCILIB_KMEM_USE_DMA_RING,(pcilib_kmem_flags_t)(PCILIB_KMEM_FLAG_EXCLUSIVE|PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_HARDWARE));
|
|
|
if( pciHandleDesc == NULL )
|
|
|
{
|
|
|
printf("Cannot allocate PCI kernel memory\n");
|
|
@@ -151,15 +151,24 @@ int main()
|
|
|
|
|
|
/* FPGA */
|
|
|
printf("\nWorking on the FPGA\n");
|
|
|
- WR32 (REG_RESET_DMA, 1);
|
|
|
- usleep (100000);
|
|
|
- WR32 (REG_RESET_DMA, 0);
|
|
|
- usleep (100000);
|
|
|
-
|
|
|
+ WR32(REG_RESET_DMA, 1);
|
|
|
+ usleep(100000);
|
|
|
+ WR32(REG_RESET_DMA, 0);
|
|
|
+ usleep(100000);
|
|
|
+ WR32_sleep(REG_NUM_PACKETS_PER_DESCRIPTOR,16);
|
|
|
+ WR32_sleep(REG_PACKET_LENGTH,64);
|
|
|
+ WR64_sleep(REG_UPDATE_ADDRESS,pciBusPage+DESCRIPTOR_OFFSET);
|
|
|
+ WR32_sleep(REG_CONTROL,CONTROL_ENABLE_READ|CONTROL_SOURCE_RX_FIFO);
|
|
|
+ WR64_sleep(REG_DESCRIPTOR_ADDRESS,pciBusDesc);
|
|
|
+ WR32_sleep(REG_DMA,1);
|
|
|
+ WR32_sleep(REG_INTERCONNECT, 0x262);
|
|
|
+ usleep(100000);
|
|
|
|
|
|
|
|
|
/* Close everything */
|
|
|
printf("\nClosing the connections\n");
|
|
|
+ pcilib_free_kernel_memory(pciCtx,pciHandleDesc,(pcilib_kmem_flags_t)(PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_HARDWARE));
|
|
|
+ pcilib_free_kernel_memory(pciCtx,pciHandlePage,(pcilib_kmem_flags_t)(PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_HARDWARE));
|
|
|
assert_cu( cuMemHostUnregister((void*) pciVa) );
|
|
|
pcilib_close(pciCtx);
|
|
|
assert_gdr( gdr_unmap(g,GPUMemHandlePage,gpuPageVa,3*PAGE_SIZE) );
|