Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FPGAX9 AWS F1 instance

4302d93d0dbd750728747bfdc8ea16c3?s=47 TT
September 24, 2017

FPGAX9 AWS F1 instance

AmazonのクラウドFPGA、F1インスタンスの開発環境でHellowWorld的なものをやってみた。

4302d93d0dbd750728747bfdc8ea16c3?s=128

TT

September 24, 2017
Tweet

Other Decks in Technology

Transcript

  1. AWS F1Πϯλϯε ࢼͯ͠Έͨ FPGAΤΫετϦʔϜɾίϯϐϡʔςΟϯά ୈ9ճ 2017/9/24 ߴڮ஌޺

  2. ࣗݾ঺հ  ߴڮ஌޺ w๺ւಓͷ΄͏͔Βདྷ·ͨ͠ wUXJUUFS!FEZ wHJUIVCFEZ wॴଐΫϥεϝιου
 "84ࣄۀ෦αʔϏεάϧʔϓ wΫϥ΢υमߦத wڵຯ

    ࢓ࣄແؔ܎  w3'৴߸ॲཧɺϥδΦଌఆث࡞Γ
  3. "84ϓϨϛΞϜίϯαϧςΟϯάύʔτφʔ ϒϩάͷձࣾ%FWFMPQFST*0 ॴଐઌʹ͍ͭͯΫϥεϝιου  ສຊ௒ͷٕज़هࣄ

  4. ຊ೔ͷ಺༰

  5. ຊ೔ͷ಺༰  w"84'Πϯελϯεʹ͍ͭͯ w'1("%FWFMPQFS".* w"84'1(")%,4%, w$-ΛϏϧυͯ͠ΈΔ w4%"DDFMΛ࢖ͬͯΈΔ w.BSLFUQMBDFͰར༻Մೳͳ࣮ྫ.JQTPMPHZ ;&#3" %FFQMFBSOJOHFOHJOFGPS$B⒎F

  6. 'Πϯελϯε  w"NB[PO"84ͷ'1("Πϯελϯε w9JMJOY6MUSB4DBMF1MVTON761 w'1("ຖʹ%%3Y(J#.5T w$16ͱͷઐ༻1$*FY w'1("Y YMBSHF '1("%JSFDU-JOL wສҎ্ͷηϧɺҎ্ͷ%41

    wΠϯελϯεͷϝϞϦͱετϨʔδ͸ผ
  7. '1("%FWFMPQFS".*  w9JMJOY։ൃπʔϧ͕͋Β͔͡ΊηοτΞοϓ͞ ΕͨϚγϯΠϝʔδ wΫϥ΢υͰ։ൃ͕Ͱ͖Δ wϥΠηϯεඅ༻ෆཁ wΠϯελϯεྉ͚ۚͩͰར༻Ͱ͖Δ wωοτͱ1$ͱΫϨΧ͕͋Ε͹0,

  8. අ༻తͳϙΠϯτ  w࣌ؒैྔྉۚͷΈͰར༻Մ w'1("Πϯελϯε)ʙ w։ൃ༻Πϯελϯεʻ) w εϙοτΠϯελϯεͳΒ͞Βʹఔ౓  wͦͷଞͷඅ༻͸ෆཁ w։ൃπʔϧͷϥΠηϯεɺϋʔυ΢ΣΞɺి

    ؾ୅ɺFUD
  9. ߏ੒  https://github.com/aws/aws-fpga/blob/master/hdk/docs/ Programmer_View.md

  10. '1("%FWFMPQFS".*  wίϚϯυϥΠϯ wαϯϓϧͰ)FMMP8PSME͢Δ͚ͩͳΒͪ͜ΒͰ0, w(6* wσεΫτοϓ؀ڥͷ௥Ճ͕ඞཁ w7/$ͷηοτΞοϓ $ sudo yum

    -y install gnome-classic-session gnome- terminal nautilus-open-terminal liberation-mono-fonts tigervnc-server.x86_64 $ vncserver -geometry 1440x900
 Password: ύεϫʔυ(2ճ) •ϙʔτϑΥϫʔυͰ઀ଓ
  11. (6* 

  12. "84'1(")%,4%,  w'Πϯελϯε޲͚ʹඞཁͳπʔϧ΍ίʔυ w(JU)VCͰఏڙ w)BSEXBSF%FWFMPQNFOU,JU w4PGUXBSF%FWFMPQNFOU,JU w4%"DDFM

  13. )BSEXBSF%FWFMPQNFOU,JU  w)%,ʹؚ·ΕΔ಺༰ wTIFMMɹ ˡ$-ΛࡌͤΔͨΊந৅Խ૚  wαϯϓϧ w$- $VTUPN-PHJD 

    w$-35- w*1* *1*OUFHSBUPS
  14. 4PGUXBSF%FWFMPQNFOU,JU  w4%,ʹؚ·ΕΔ಺༰ wMJOVY@LFSOFM@ESJWFS wFENBYENBYDMENB wVTFSTQBDF w؅ཧίϚϯυ܈ wϗετ༻ϥΠϒϥϦ

  15. 4%"DDFM  wιϑτ΢ΣΞ։ൃऀʹ༏͍͠'1("։ൃ؀ڥ w"844%,Ͱ("ʹͳͬͨ   w9JMJOYͷαϯϓϧ͕Πϯϙʔτ͞ΕΔ
 IUUQTHJUIVCDPN9JMJOY4%"DDFM@&YBNQMFT

  16. HelloWorldͯ͠ΈΔ

  17. '1("%FWFMPQFS".*ͰΠϯελϯε࡞੒  wϚωʔδϝϯτίϯιʔϧ͔ΒΠϯελϯε࡞੒ w.BSLFUQMBDF·ͨ͸ίϛϡχςΟ".*͔ΒGQHB ͱೖྗͯ͠ݕࡧ wΠϯελϯελΠϓ wϝϞϦཁ݅ʼ(J# wNYMBSHFҎ্·ͨ͸DYMBSHFҎ্ਪન

  18. 44)ϩάΠϯͨ͠Β  $ cd src/project_data $ git clone https://github.com/aws/aws-fpga $

    cd aws-fpga $ source hdk_setup.sh BXTGQHBΛμ΢ϯϩʔυˍηοτΞοϓ
  19. Πϝʔδ࡞੒·Ͱͷखॱ֓ཁ  wαϯϓϧͷ৔ॴ waws-fpga/hdk/cl/example/cl_hello_world wϏϧυ d࣌ؒ  wUBSΛ4ʹΞοϓϩʔυ w"'*࡞੒ΛϦΫΤετ͢Δ ਺े෼

  20. Ϗϧυ  $ cd hdk/cl/example/cl_hello_world $ export CL_DIR=$(pwd) $ build/scripts/aws_build_dcp_from_cl.sh

    ίϚϯυྫ
  21. ΞοϓϩʔυͱΠϝʔδ࡞੒ϦΫΤετ  $ aws s3 mb s3://cl_hello_world_01 $ aws s3

    mb s3://cl_hello_world_01/dcp $ aws s3 mb s3://cl_hello_world_01/log $ aws s3 cp build/checkpoints/to_aws/ *.Developer_CL.tar s3://cl_hello_world_01/dcp/ ίϯιʔϧ͔ΒόέοτϙϦγʔͰΞΫηεΛڐՄ͢ΔΑ͏ઃఆ $ aws ec2 create-fpga-image --name cl_hello_world --description cl_hello_world --input- storage-location Bucket=cl_hello_world_01,Key=dcp/17_04_26-145828.Developer_CL.tar -- logs-storage-location Bucket=cl_hello_world_01,Key=log { "FpgaImageId": "afi-123456789XXXXXXXX", "FpgaImageGlobalId": "agfi-0987654321XXXXXXXXXXXX" } AFI ID,AGFI ID͕දࣔ͞ΕΔͷͰϝϞ͓ͬͯ͘
  22. Πϝʔδ࡞੒׬ྃ֬ೝ  •AFI͕࡞੒׬͍ྃͯ͠Δ͔Λ֬ೝ • aws ec2 describe-fpga-images --fpga-image-ids afi-0f0927bc2649e6259 {

    "Name": "cl_hellow_world", ... "FpgaImageGlobalId": "agfi-0f0e045f919413242", "Public": false, "State": { "Code": "available" }, "FpgaImageId": "afi-0f0927bc2649e6259", "Description": "cl_hello_world" }
  23. '̍Πϯελϯεʹϩʔυ͢Δ  w'ΠϯελϯεΛىಈ w Ϧʔδϣϯ/7JSHJOJB w '1("%FWFMPQFS".*Λ࢖༻ wBXTDPOpHVSFͰ*".ΩʔΛઃఆ $ cd

    src/project_data $ git clone https://github.com/aws/aws-fpga $ cd aws-fpga $ source sdk_setup.sh ←πʔϧྨ͕Πϯετʔϧ͞ΕΔ AFGIΛࢦఆͯ͠ɺΠϝʔδΛϩʔυˍ֬ೝ
  24. ಈ͔ͯ͠ΈΔ  •ϥϯλΠϜΛߏங •ಈ͔ͯ͠ΈΔɻDEADBEEFΛॻ͍ͨΒDEADBEEF͕ಡΊͨʂ

  25. 7JSUVBM%*148ͱ-&%  •16ϏοτͷGPIO͕͋Γɺιϑτ΢ΣΞతʹIOՄೳ •fpga-set-virtual-dip-switch •fpga-get-virtual-led •DIPΛૢ࡞͢ΔͱLED͕มԽ͢Δͷ͕֬ೝͰ͖Δ

  26. "'*͸γΣΞͰ͖ΔΒ͍͠  •FAQʹΑΔͱ࡞੒ͨ͠AFI͸ڞ༗Մೳͱͷ͜ͱ •ΠϝʔδͷϓϩύςΟʹPublic͕͋Δɻ
 ͜ΕΛtrueʹઃఆ͔ɻ { "Name": "cl_hellow_world", ... "FpgaImageGlobalId":

    "agfi-0f0e045f919413242", "Public": false, "State": { "Code": "available" }, "FpgaImageId": "afi-0f0927bc2649e6259", "Description": "cl_hello_world" } 
  27. FENBυϥΠό  $ cd aws-fpga/sdk/linux_kernel_drivers/edma $ sudo yum groupinstall "Development

    tools" $ sudo yum install kernel-devel $ echo 'edma' | sudo tee --append /etc/modules-load.d/ edma.conf $ sudo cp edma-drv.ko /lib/modules/`uname -r`/ $ sudo depmod $ sudo modprobe edma-drv` •edmaυϥΠό͸AMIʹΠϯετʔϧࡁΈͱॻ͔Ε͍ͯΔ͕ɺͳ ͔ͥೖ͍ͬͯͳ͍ɻखಈͰೖΕΔɻ aws-fpga/sdk/linux_kernel_drivers/edma/edma_install.md
  28. DM@ESBN@ENBΛࢼ͢ɺ͕ࣦഊ  •΋͏Ұͭαϯϓϧ cl_dram_dma Λࢼͨ͠ɻ •લड़ͷΑ͏ʹखಈͰೖΕΔɻ •ΠϝʔδΛ࡞੒&ϩʔυɻϥϯλΠϜΛmake࣮ͯ͠ߦɻ •ΤϥʔͰࣦഊɻrescan/rmmod/insmodͰ΋มԽͤͣɻ $ sudo

    ./test_dram_dma The slot appears loaded, but the pci vendor or device ID doesn't match the expected values You may need to rescan the fpga with fpga-describe-local-image -S 0 -R Note that rescanning can change which device file in /dev/ a FPGA will map to. To remove and re-add your edma driver and reset the device file mappings, run `sudo rmmod edma-drv && sudo insmod <aws-fpga>/sdk/linux_kernel_drivers/edma/edma-drv.ko` 2017-09-23T21:44:45.594093Z, test_dram_dma, ERROR, test_dram_dma.c +97: check_slot_config( The PCI vendor id and device of the loaded image are not the expected values. 2017-09-23T21:44:45.594150Z, test_dram_dma, ERROR, test_dram_dma.c +149: dma_example(): sl config is not correct 2017-09-23T21:44:45.594154Z, test_dram_dma, ERROR, test_dram_dma.c +58: main(): DMA exampl failed
  29. SDAccelΛͨΊ͢

  30. ४උ  w'1("%FWFMPQFS".*Λىಈͨ͠ΒɺԼهίϚ ϯυͰ४උ $ sudo yum install -y libstdc++-static

    gdb opencv libjpeg- turbo-devel libpng12-devel libtiff-devel compat-libtiff3 $ cd src/project_data $ git clone https://github.com/aws/aws-fpga $ cd aws-fpga $ source sdaccel_setup.sh $ source $XILINX_SDX/settings64.sh
  31. IFMMPXPSME@PDMΛϏϧυ͢Δ  wλʔήοτ͕छྨ wTX@FNVɹιϑτ΢ΣΞΤϛϡϨʔγϣϯ wIX@FNVɹϋʔυ΢ΣΞΤϛϡϨʔγϣϯ wIXɹ࣮ػ޲͚ NBLFDIFDL5"3(&54TX@FNV%&7*$&4"84@1-"5'03.BMM

  32. IFMMPXPSME@PDMͷ࣮ߦ݁Ռ  w Λฒྻ࣮ߦ 

  33. ϋʔυ΢ΣΞ޲͚ͷߏங  wNBLFͰ࡞੒ ͕͔͔࣌ؒΔ  wYDMCJOʹͰ͖ͨϑΝΠϧͱɺ4όέοτΛࢦఆͯ͠ɺ DSFBUF@TEBDDFM@BpTIΛ࣮ߦ w ͏·͍͚͘͹"'*Πϝʔδ͕࡞੒͞ΕΔ $

    make check TARGETS=hw DEVICES=$AWS_PLATFORM all $ $SDACCEL_DIR/tools/create_sdaccel_afi.sh -xclbin=xclbin/vector_addition.hw.xilinx_aws- vu9p-f1_4ddr-xpr-2pr_4_0.xclbin -o=vector_addition.hw.xilinx_aws-vu9p-f1_4ddr- xpr-2pr_4_0 -s3_bucket=cl_hello_world_01 -s3_dcp_key=dcp -s3_logs_key=log
  34. ϋʔυ΢ΣΞͰ࣮ߦ͢Δ  w'1("'ΠϯελϯεͰϗετΞϓϦΛىಈ DETSDQSPKFDU@EBUBBXTGQHB4%"DDFMFYBNQMFTYJMJOYHFUUJOH@TUBSUFEIPTU IFMMPXPSME@PDM TVEPTI TPVSDFPQU9JMJOY4%YSUFTFUVQTI IFMMPXPSME

  35. 4%"DDFMͰ)FMMP8PSME  wࣗಈతʹΠϝʔδ͕ϩʔυ͞Ε࣮ͯߦ

  36. ผͳαϯϓϧIJHI@QFSG@NBU@NVMU  $ cd src/project_data/aws-fpga/SDAccel/examples/xilinx/acceleration/high_perf_mat_mult/ $ sudo sh sh-4.2# source

    /opt/Xilinx/SDx/2017.1.rte/setup.sh sh-4.2# ./high_perf_mat_mult 1000 1000 200 Creating context... Device/Slot[0] (/dev/xdma0, 0:0:1d.0) xclProbe found 1 FPGA slots with XDMA driver running INFO: Importing ./high_perf_mat_mult0.hw.xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4_0.awsxclbin INFO: Loaded file Successfully skipped reloading of local image. INFO: Created Binary INFO: Built Program INFO: input matrix size: M= 1024, N= 1024, K= 256 INFO: hw matrix size: row= 32, col= 16, depth= 256 Creating Buffers... Copying Buffers to device.... Copying results to host.... INFO: Execution done INFO: kernel time 0.000789 seconds numOfOps 536870912.000000 Efficiency: 680.511168 GOPs INFO: Test Passed
  37. None
  38. Marketplaceʹ͋Δ FPGAιϦϡʔγϣϯ

  39. "84.BSLFUQMBDF  wύʔτφʔ͔Β'1("ιϦϡʔγϣϯ͕͍͔ͭ͘ ఏڙ͞Ε͍ͯΔ

  40. .JQTPMPHZ;&#3"Λࢼͯ͠Έͨ 

  41. ྉۚ  wιϑτ΢ΣΞ Πϯελϯεྉۚ w࣌ؒैྔྉۚ ผͷܗࣜ΋͋Δ  w[FCSBͷ৔߹ɺ )

  42. ΠϯελϯεΛىಈ  w".*;FCSB%FFQ-FBSOJOHFOHJOF wGYMBSHF w͋ͱ͸σϑΥϧτͰ0,

  43. σϞΛىಈ  wTTIͰ઀ଓɺd.JQTPMPHZ7 FYBNQMFTSVO@EFNP8FCTIΛىಈ w ৄࡉˠIUUQXXXNJQTPMPHZDPNBXTHFUUJOH@TUBSUFEIUNM

  44. ϒϥ΢βͰ։͘  wϒϥ΢βͰ1VCMJD*1Λ։͘

  45. ඵؒຕͷը૾Λ෼ྨ  wॲཧঢ়گ͕ৗ࣌ߋ৽ GSBNFTTఔ౓ग़ͯΔ

  46. ·ͱΊ  w"84'Πϯελϯε wBXTGQHB)%,4%,4%"DDFM w͍͔ͭ͘ͷαϯϓϧΛࢼͨ͠ w͏·͍͔͘ͳ͍έʔε΋ ଟ෼Կ͔ؒҧͬͨ  w.JQTPMPHZ;FCSBΛࢼͨ͠ σϞ

  47. ͋Γ͕ͱ͏͍͟͝·ͨ͠