Академический Документы
Профессиональный Документы
Культура Документы
OCL001-13.1.1 2013.12.13
TOC-2
Contents
Altera SDK for OpenCL Getting Started Guide.................................................1-1
About Altera SDK for OpenCL Getting Started Guide..........................................................................1-1 Prerequisites..................................................................................................................................................1-1 Overview of the AOCL Setup Process.......................................................................................................1-2 Downloading the Software.........................................................................................................................1-4 Installing the AOCL and the Quartus II Software Together..................................................................1-5 Setting Up the AOCL as a Stand-Alone Software...................................................................................1-5 Installing and Uninstalling the AOCL on Windows..................................................................1-5 Installing and Uninstalling the AOCL on Linux.........................................................................1-6 Installing an FPGA Board...........................................................................................................................1-7 Creating the FPGA Hardware Configuration File of an OpenCL Kernel............................................1-8 Updating the Hardware Image on the FPGA..........................................................................................1-9 Programming the Flash Memory of an FPGA.............................................................................1-9 Setting Up the Host Application..............................................................................................................1-10 Building and Running the Host Application on Windows......................................................1-11 Building and Running the Host Application on Linux............................................................1-11 AOC Output from Successful Kernel Execution.......................................................................1-12 Conclusion..................................................................................................................................................1-13 Document Revision History.....................................................................................................................1-13
Altera Corporation
OCL001-13.1.1
Subscribe
Send Feedback
OpenCL Reference Pages Refer to the OpenCL Reference Pages for more information on the OpenCL Specification verison 1.0. OpenCL Specification version 1.0 Refer to the OpenCL Specification version 1.0 for detailed information on the OpenCL application programming interface (API) and programming language.
Prerequisites
To install the AOCL and create an OpenCL application for an Altera preferred FPGA board, your system must meet certain hardware, operating system (OS), and software requirements.
(1) (2)
OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission of the Khronos Group. The Altera SDK for OpenCL is based on a published Khronos Specification, and has passed the Khronos Conformance Testing Process. Current conformance status can be found at www.khronos.org/conformance.
ISO 9001:2008 Registered
2013 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX words
and logos are trademarks of Altera Corporation and registered in the U.S. Patent and Trademark Office and in other countries. All other words and logos identified as trademarks or service marks are the property of their respective holders as described at www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordance with Altera's standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes no responsibility or liability arising out of the application or use of any information, product, or service described herein except as expressly agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products or services.
www.altera.com
101 Innovation Drive, San Jose, CA 95134
1-2
OCL001-13.1.1 2013.12.13
Host System Requirements To install an Altera preferred FPGA board, the host system must meet the following minimum hardware and OS requirements: The preferred accelerator board contains Stratix V FPGAs. The host system has at least 24 gigabytes (GB) of RAM. The host system must be running a 64-bit OS. Any binaries that your system builds must be 64-bit executables. The AOCL supports the following OS: Microsoft 64-bit Windows 7. Red Hat Enterprise 64-bit Linux (RHEL) 5.6. Important: You must install the Linux OS kernel source and headers, and the GNU Compiler Collection (GCC). Caution: You must have administrator privileges on the host system to install the necessary packages and drivers. The host machine motherboard must have at least one eight-lane PCI Express port (PCIe x8). If an eight-lane port is not available, you may use a sixteen-lane (PCIe x16) port. Software Prerequisites Ensure that the version of your C compiler or software development environment is compatible with the current version of the AOCL and Quartus II software. Build your host executable code using the following C compiler or software development environment: For Windows systems, use Microsoft Visual Studio verison 2010 Professional. For Linux systems, use the C compiler included with the GCC.
Altera Corporation
OCL001-13.1.1 2013.12.13
1-3
Review prerequisites
NO
Install Quartus II software, Stratix V device support, AOCL NO NO YES Install FPGA board (aocl install) aocl diagnostic = PASSED? YES Run hello_world on FPGA
After you complete the initial software and hardware setup successfully, you can create a hardware image from the hello_world example OpenCL application. Before you program your FPGA with the hardware image, ensure that your FPGA contains an image created using a current version of the AOCL. The figure below summarizes the steps you perform to program your FPGA.
Altera Corporation
1-4
OCL001-13.1.1 2013.12.13
Select target FPGA board (aoc --list-boards) hello_world.aoco Compile kernel for target board (aoc -v --board <board_name> hello_world.cl) hello_world.aocx
NO
Build successful?
NO
Altera Corporation
OCL001-13.1.1 2013.12.13
1-5
5. If you install the AOCL as part of the Quartus II software, perform the following steps: a. Under the Individual Files tab, select to download the Quartus II software package and the Stratix V device support. b. Under the Additional Software tab, select to download the Altera SDK for OpenCL. The Quartus II software installer installs the Quartus II software, the Stratix V device support, and the AOCL. 6. If you install the AOCL as a standalone software, only select the Altera SDK for OpenCL under Additional Software. The AOCL installer installs the AOCL without the Quartus II software and the Stratix V device support. 7. Perform the steps outlined in the download and installation instructions on the download page.
Altera Corporation
1-6
OCL001-13.1.1 2013.12.13
Before you begin Attention: You must have administrator privileges. 1. Direct the installer AOCLSetup-<version>.exe to extract the AOCL to an empty folder that you own, not a system folder (for example, C:\altera\<version>\hld). Caution: The path must not contain any spaces. 2. Verify that the environment variables listed below are set.
Environment Variable Path Added
Environment variables set by the installer: ALTERAOCLSDKROOT <path_to_hld>, which is the absolute path to the folder containing the extracted installation package
3. Verify the successful installation of the AOCL by performing the following tasks: a. Run the cmd.exe executable. b. Type the where aoc command. If the path to the aoc.exe file is not returned, installation was unsuccessful. If installation was unsuccessful, reinstall the AOCL.
Altera Corporation
OCL001-13.1.1 2013.12.13
1-7
1. Direct the installer AOCLSetup-<version>.run to extract the AOCL to an empty directory that you own, not a system directory (for example, /usr/altera/<version>/hld). Caution: The path must not contain any spaces. 2. Verify that the environment variables listed below are set.
Environment Variable Path Added
Environment variables set by the installer: ALTERAOCLSDKROOT <path_to_hld>, which is the absolute path to the directory containing the extracted installation package
Warning: If you install the AOCL on a system that does not contain any C Shell Resource file (.cshrc) or Bash Resource file (.bashrc) in your directory, you must set the environment variables ALTERAOCLSDKROOT and PATH manually. Alternatively, you may create the .cshrc and .bashrc files, and then append the environment variables to them. To ensure that the updates take effect, restart your terminal after you set the environment variables.
1-8
OCL001-13.1.1 2013.12.13
4. Set the environment variable AOCL_BOARD_PACKAGE_ROOT to the local folder or directory in Step 3. 5. Invoke the command aocl install at a command prompt. Important: By invoking the aocl install command, you also install a board driver that allows communication between host programs and hardware kernel programs. 6. To verify the successful installation of the FPGA board, invoke the command aocl diagnostic to run any board vendor-recommended diagnostic test.
Altera Corporation
OCL001-13.1.1 2013.12.13
1-9
Attention: The .aocx file might take hours to build, depending on the complexity of the kernel. To view the progress of the compilation on-screen, include the -v flag in your aoc command. An example output is shown below. $ aoc --board pcie385n_a7 -v hello_world.cl aoc: Environment checks are completed successfully. You are now compiling the full flow!! aoc: Selected target board pcie385n_a7 aoc: Running OpenCL parser.... aoc: OpenCL parser completed successfully. aoc: Compiling.... aoc: Linking with IP library ... aoc: First stage compilation completed successfully. aoc: Running Quartus design generator.... aoc: Quartus design generator completed successfully. aoc: Compiling Quartus project. aoc: Hardware generation completed successfully. When the line aoc: Compiling Quartus project. appears, it signifies the beginning of the hardware build, which is the time-consuming part of the compilation process. The AOC displays the line aoc: Hardware generation completed successfully. to signify the completion of the compilation process.
Related Information
Installing an FPGA Board on page 1-7 Altera SDK for OpenCL Programming Guide For more information on the --list-boards and --board <board_name> options of the aoc command, refer to the AOC Modifiers section of the AOCL Programming Guide. For more information on the -v option of the aoc command, refer to the -v section of the AOCL Programming Guide.
1-10
OCL001-13.1.1 2013.12.13
flash memory of the FPGA with an OpenCL-compatible image. If the system fails to configure the PCIe device in your FPGA board properly, the default image in the flash memory will configure the FPGA and instantiate the PCIe device. Caution: When you load the hardware configuration file into the flash memory of the FPGA, do not power down the system prematurely. Also, do not launch any host code that calls OpenCL kernels or might otherwise communicate with the FPGA board. To load your hardware configuration file into the flash memory of your FPGA board, perform the following tasks: 1. If applicable, for a Windows system, install the USB-Blaster driver so that you can load your hardware configuration file into the flash memory. For installation instructions, refer to the USB-Blaster Driver for Windows 7 and Windows Vista page on the Altera website. Note: If you have a Linux system, proceed to Step 2. RHEL 5.6 host systems natively include the USB driver. 2. Ensure that you set the AOCL_BOARD_PACKAGE_ROOT environment variable to the board package that corresponds to your FPGA board (that is, ALTERAOCLSDKROOT/board/<board_family>). 3. At a command prompt, navigate to the hello_world design. Remember: You can download the hello_world design from the OpenCL Design Examples page, and extract the example to a location to which you have write access. 4. Invoke the command aocl flash hello_world.aocx to load the hardware configuration file into the flash memory. 5. Power down your host machine and then power it up again. Warning: If you do not power down your host machine after you program the flash memory, you might not have a valid image loaded onto your FPGA.
Altera Corporation
OCL001-13.1.1 2013.12.13
1-11
Altera Corporation
1-12
OCL001-13.1.1 2013.12.13
= Altera SDK for OpenCL = Altera Corporation = OpenCL 1.0 Altera SDK for OpenCL, Version 13.1
Querying device for info: ======================== CL_DEVICE_NAME = pcie385n_a7 : PCIe-385N Altera Stratix V Computing Card CL_DEVICE_VENDOR = Nallatech Inc. CL_DEVICE_VENDOR_ID = 4466 CL_DEVICE_VERSION = OpenCL 1.0 Altera SDK for OpenCL, Version 13.1 CL_DRIVER_VERSION = 13.1 CL_DEVICE_ADDRESS_BITS = 64 CL_DEVICE_AVAILABLE = true CL_DEVICE_ENDIAN_LITTLE = true CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 32768 CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0 CL_DEVICE_GLOBAL_MEM_SIZE = 0 CL_DEVICE_IMAGE_SUPPORT = false CL_DEVICE_LOCAL_MEM_SIZE = 16384 CL_DEVICE_MAX_CLOCK_FREQUENCY = 1000 CL_DEVICE_MAX_COMPUTE_UNITS = 1 CL_DEVICE_MAX_CONSTANT_ARGS = 8 CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 1073741824 CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 3 CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 1024 CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 128 CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 4 CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 2 CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = 1 CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 1 CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 1 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0 Command queue out of order? = false Command queue profiling enabled? = true
Altera Corporation
OCL001-13.1.1 2013.12.13
Conclusion
1-13
Kernel initialization is complete. Launching the kernel... Thread #2: Hello from Altera's OpenCL Compiler! Kernel execution is complete.
Conclusion
You have performed successfully all the steps necessary to execute an OpenCL application on a preferred FPGA-based accelerator board. You may follow the same steps to execute a different OpenCL example application using the AOCL. For more in-depth explanation on the features of the AOCL, refer to the Altera SDK for OpenCL Programming Guide. The programming guide also serves as a general guide to writing OpenCL applications with the AOCL. The Altera SDK for OpenCL Optimization Guide helps you master optimization techniques for AOCL applications. Both guides are available on the AOCL documentation page of the Altera website.
Related Information
Altera SDK for OpenCL Programming Guide Refer to the AOCL Programming Guide for guidelines on creating OpenCL applications using the AOCL. Altera SDK for OpenCL Optimization Guide Refer to the AOCL Optimization Guide for guidelines on optimizing your OpenCL applications using the AOCL.
December 2013
13.1.1
Updated the Prerequisites section to include a reminder to install Linux kernel source, headers, and GCC.
Altera Corporation
1-14
OCL001-13.1.1 2013.12.13
Date
Version
Changes
November 2013
13.1.0
Reorganized information flow. Updated the Prerequisites section. Updated board installation instructions. Updated software download instructions. Inserted the section Installing the AOCL and the Quartus II Software Together. Updated software installation and uninstallation instructions. Inserted the following figures: AOCL Installation Process Overview FPGA Programming Overview Removed the Licensing section. Removed all board-specific installation and configuration instructions. Changed example OpenCL application used to demonstrate kernel configuration and FPGA programming from moving_average to hello_world. Inserted the section Updating the Hardware Image on the FPGA, which contained the updated flash programming instructions. Removed the section Installing the USB-Blaster Driver on Windows. Updated output from successful execution of hello_world kernel on FPGA for Windows and Linux systems. Removed the figure Contents of the Moving Average Example. Removed the figure Opening host.sln in Visual Studio.
June 2013
13.0 SP1.0
Updated requisite Quartus II and AOCL software versions from 13.0 to 13.0 SP1. Inserted the figure A Correct Windows Device Manager After Complete Board Driver Installation for a BittWare Board. Updated the vendor and device IDs in the Verifying the Functionality of the BittWare Board section for Windows. Updated the AOCL installation instructions for Linux systems that do not contain a .cshrc or a .bashrc file in the directory. Updated path to the AOCL design examples. Updated the figure Contents of the Moving Average Example. Updated flash programming instructions.
Altera Corporation
OCL001-13.1.1 2013.12.13
1-15
Date
Version
Changes
May 2013
13.0.1
Renamed the OpenCL_SDK folder or directory to AOCL. Inserted warning about the AOCL installation dependency on .cshrc and .bashrc files for Linux systems. Included reminder to BittWare board users about installing the BittWare development software. Inserted warning about potential Jungo WinDriver installation failure for systems running on Windows 7. Included reinstallation instructions. Inserted warnings about error messages displayed for aocl commands that have not been implemented for the BittWare FPGA board. Inserted caution message about setting the environment variable AOCL_BOARD_PACKAGE_ROOT. Updated board driver installation procedures for Windows and Linux systems. Modified the path to the default location of the AOCL for Windows and Linux systems. Modified the path name added to the PATH environment variable when installing the AOCL on Linux systems. The path name should be $QUARTUS_ROOTDIR/bin instead of $QUARTUS_ROOTDIR/bin64. Updated installation and compilation procedures. Incorporated licensing procedure. Updated flash programming procedure and moved it to Appendix A. Updated links to software and documentation download pages.
May 2013
13.0.0
November 2012
12.1.0
Initial release.
Altera Corporation