Teach you how to quickly learn Alibaba Cloud FaaS F2

Foreword

Alibaba Cloud Virtualization Team Heterogeneous Computing and High Performance Computing Team has been working on "popularization" of computing resources; the term civilianization was first heard from the high performance computing team, He Wanqing, who was doing it. E-HPC is to enable all users on the cloud to instantly have a small super-computing cluster, so that the use of super-calculation is no longer just a privilege of some super-computing centers and universities; our heterogeneous computing team is committed to being the fastest The latest computing device is provided to users on the cloud. The previous product was the GPU cloud server EGS . About half a year ago, we officially launched the FPGA cloud server FaaS . After internal testing, public beta, it is finally officially launched, users only need to open the white list. You can use FPGA resources just like you would with an ECS virtual machine!

FaaS Introduction

FaaS, full name FPGA as a Service, is a way to use FPGAs on the cloud; we now support two different examples, namely:

Example Model FPGA Model
F1 Intel A10
F2 Xilinx ku115

F2 from entry to give up

ready

New sub-account (optional)

It is recommended that the user create a new sub-account and use the sub-account to operate the Alibaba Cloud resource, and ensure the security by authorizing the necessary permissions of the sub-account!

1. Log in to Ali Cloud RAM Console

2. Select [User Management] -> [New User] in the left sidebar position

3. Fill in the form of the created user pop-up: user name, display name, email address, phone number, etc. **Select to automatically generate AccessKey** for this user, click OK

4. Save the user's AK/AS in the pop-up window. Please remember to use AK/AS here. You will need this information for subsequent operations!

5. At this point, the RAM sub-account has been created, and you need to authorize the sub-account!

6. In the RAM console, select the [User Management] tab on the left, you can see the newly created RAM sub-account, click the [Authorize] button, and perform sub-account authorization.

7. Grant at least the following permissions to the sub-account: AliyunOSSFullAccess, AliyunECSFullAccess, AliyunRAMFullAccess & AliyunSTSAssumeRoleAccess; click OK when selected

Open OSS and create a dedicated bucket

FaaS's mirror-related operations depend on Alibaba Cloud OSS storage, so users must open OSS services; we also recommend that users create a new proprietary bucket to store your own FPGA image intermediate results.

Open OSS (if you have already opened, please ignore this step)

1. Log in to the OSS sales page and click to open it immediately.

Create a new bucket in East China 1

It is recommended that the user create a new bucket, which is used exclusively for the FaaS service. Therefore, this bucket will open the read and write permissions for the official account of aliyun. Therefore, it is not recommended that the user store and FaaS irrelevant content; **Please remember this bucket name in the subsequent operation. Will often use **

1. Log in to the OSS Management Console

2. Click the "+" sign at the top left to create a new bucket.

3. In the dialog box that pops up on the right, give the bucket a name, select the area as ** East China 1**, click OK

4. You can see the bucket you just created on the left side.

Buy To budget is relatively tight, buy users paying by volume: Considering that the price of F2 instance is higher than the price of ordinary ECS, it is recommended that users use ordinary ECS during debugging and compiling stage; it is recommended to use Alibaba Cloud computing instance, more than 4 cores; After debugging and compiling, you need to download the F2 instance when you really need to download it to the FPGA.

1. The current F2 instance still needs to open a whitelist. Please ask the user to submit a work order (or contact Alibaba Cloud BD) to provide your own Alibaba Cloud account.

2. After opening the white list, purchase directly on the Alibaba Cloud official website purchase page , please select East China 1, Availability Zone B, VPC network; F2 currently supports ** pay-per-use** and **annual subscription month** For example specifications, please select **Heterogeneous calculation**, **FPGA calculation type**

3. Xilinx development environment, we have prepared a mirror, the user can directly use the image to create an instance; the image will be provided to the user in the mirror market for free, and can only be provided by sharing the image, so the user is choosing When mirroring, please select **shared image**; if you can't see the image in the shared image, you need to pick up the work order (or contact Alibaba Cloud BD)

F2 instance OpenCL development best practices

Here we use the common computational example to compile and simulate, taking the F2 instance as the final run as an example; of course, the compilation and simulation can also be done on the F2 instance, which makes it easier to compile and simulate.

For volume users, it is recommended to use a cheaper common ECS instance (recommended to use a computational quad core or more) for compilation and simulation, because you don't need to actually use the FPGA at this time; buying a normal ECS instance is similar to buying an F2 instance, just in When choosing an instance specification, choose a different model, but ** still use our shared image**

1. First configure the SDx environment source /opt/Xilinx/SDx/2017.2/settings64.sh2. Run SDx with demo:cd /opt/Xilinx/SDx/2017.2/examples/vadd

Check whether the platform (line 60) in sdaccel.mk in the current directory is XDEVICE=xilinx_kcu1500_4ddr-xpr_4_0

Change the common.mk file vim ../common/common.mk

Put line 61 CLCC_OPT += $(CLCC_OPT_LEVEL) ${DEVICE_REPO_OPT} --platform ${XDEVICE} -o ${XCLBIN} ${KERNEL_DEFS} ${KERNEL_INCS}

Change to CLCC_OPT += $(CLCC_OPT_LEVEL) ${DEVICE_REPO_OPT} --platform ${XDEVICE} -o ${XCLBIN} ${KERNEL_DEFS} ${KERNEL_INCS} --xp param:compiler.acceleratorBinaryContent=dcp

Software simulation make -f sdaccel.mk run_cpu_em

See if the result is PASSED

Run export XCL_EMULATION_MODE=true directly #must set this environment variable, otherwise it will report an error, can not find the device. /vadd bin_vadd_cpu_emu.xclbin# If the following error is reported: Error: Unable to find Target Device xilinx_kcu1500_4ddr-xpr_4_0; please check whether XCL_EMULATION_MODE is True, if not, set: export XCL_EMULATION_MODE=true

Hardware emulation make -f sdaccel.mk cleanallmake -f sdaccel.mk run_hw_em

See if the simulation results are PASSED

Run export XCL_EMULATION_MODE=true directly #must set this environment variable, otherwise it will report an error, can not find the device. /vadd bin_vadd_cpu_emu.xclbin# If the following error is reported: Error: Unable to find Target Device xilinx_kcu1500_4ddr-xpr_4_0; please check whether XCL_EMULATION_MODE is True, if not, set: export XCL_EMULATION_MODE=true

Compile make -f sdaccel.mk cleanallmake -f sdaccel.mk xbin_hw

//Other operations/*make -f sdaccel.mk xbin_hw #Generate the final binary file for a long time, almost 4 hours to complete make -f ./sdaccel.mk help #View help documentation #Compile and run CPU emulation Using default xilinx:adm-pcie-7v3:1ddr:3.0 DSAmake -f sdaccel.mk run_cpu_em //Software emulation #Compile and run hardware emulation using default xilinx:adm-pcie-7v3:1ddr:3.0 DSAmake -f sdaccel. Mk run_hw_em //hardware emulation #Compile host executable onlymake -f sdaccel.mk host //only compile the host code#Compile XCLBIN file for system run onlymake -f sdaccel.mk xbin_hw //This is the most important, compile and generate can be downloaded to the FPGA Binary file #Clean working diretory#make -f sdaccel.mk clean#Super clean working directory#make -f sdaccel.mk cleanall*/

Ps: The compilation time will be longer. It is recommended to prevent ssh timeout from exiting through screen or nohub.

3. Configure a secure burning environment

Source /root/xbinst_oem/F2_env_setup.shfaascmd config --id= --key= #id/key is Alibaba Cloud accessID/accessKey, the above new sub-account has been saved

Faascmd auth --bucket= #New OSS bucket name

4. After the compilation is successful, the package is closed.

#If there is no sdaccel_package.sh in the /root/xbinst_oem/ directory, first download: wget http://fpga-tools.oss-cn-shanghai.aliyuncs.com/sdaccel_package.sh /root/xbinst_oem/sdaccel_package.sh -xclbin= /opt/Xilinx/SDx/2017.2/examples/vadd/bin_vadd_cpu_emu.xclbin

5. Upload the compressed package to your own OSS designated bucket

Faascmd upload_object --object=<name in bucket, it is recommended to be consistent with file> --file=<package generated result, a tarball>

6. Create a new FPGA image that can be run on F2

Faascmd create_image --object=<name in bucket, it is recommended to be consistent with file> --fpgatype=xilinx --name=hereIsFPGAImageName --tags=hereIsFPGAImageTag --encrypted=false --shell=V1.0

7. Check if fpga image is available for download.

We see that the status is already success and can be downloaded. Write down the FPGAIamgeUUID and use it when you download it.

download

How to compile and simulate is done on another ECS, here we must first purchase an F2 instance; the specific purchase process reference ** purchase ** chapter

1. First configure the secure programming environment (if it has been set before, skip) source /root/xbinst_oem/F2_env_setup.sh

Faascmd config --id= --key= #id/key is Alibaba Cloud accessID/accessKey, the above new sub-account has been saved

Faascmd auth --bucket= #New OSS bucket name

2. Get fpgauuidfaascmd list_instances --instanceId=hereIsYourInstanceIdvm instance Id: can be found in Alibaba Cloud Console

3. Download fpga imagefaascmd download_image --instanceId=hereIsYourInstanceId --fpgauuid=hereIsFpgaUUID --fpgatype=xilinx --imageuuid=hereIsImageUUID --imagetype=afu --shell=V1.0

4. Check if the download is successful faascmd fpga_status --fpgauuid=hereIsFpgaUUID --instanceId=hereIsYourInstanceId

The FpgaImageUUID on the board has been consistent with the image to be downloaded, and the TaskStatus has been valid, indicating that the download has been successful.

5. Run the host program

Make -f sdaccel.mk hostunset XILINX_SDX./vadd bin_vadd_hw.xclbin


DC Capacitor For Electric Furnace

DC Capacitor For Electric Furnace

DC Capacitor For Electric Furnace,DCMJ DC Filter Capacitors,DCMJ Pulse Capacitors,DCMJ DC Support Capacitors

YANGZHOU POSITIONING TECH CO., LTD. , https://www.cnchipmicro.com

Posted on