Creating an Application Project

Creating a Template Project

  1. Navigate to the project creation window.
    • On the MindStudio welcome page, choose Project from the left menu and click New Project on the right.
      Figure 1 Project creation page
    • On the MindStudio project page, choose File > New > Project... from the top menu bar.
  2. In the New Project window, select Ascend App and specify the project type. See Figure 2. Then click Next to enter the project configuration page. (If the project type name is not completely displayed, hover the cursor on the name to display the complete name.)

    CANN Version: indicates the activated CANN version. You can click Change on the right to change the CANN version. For details, see Switching/Activating a CANN Package.

    AscendCL Project is an empty project of AscendCL, containing only the development framework but no specific code logic.

    If CANN is not configured in MindStudio, some application projects may not be properly displayed.

    Figure 2 AscendCL application project
  3. Access the project configuration page and set project parameters listed in Table 1.
    Table 1 Project parameters

    Parameter

    Description

    Project name

    Project name (user-defined).

    The name contains a maximum of 64 characters and must start and end with a digit or letter. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    Project location

    Default path for saving a project (user-defined). (For users who use MindStudio for the first time, the default value is $HOME/MindstudioProjects)

    More Settings

    Module name: module name, the same as the Project name.

    Content root: path in the root directory.

    Module file location: module file path.

    Click the check box on the right of Project format. A drop-down list is displayed.
    • .idea (directory-based) (default option): During project creation, an .idea option is created to save the project information.
    • .ipr (file-based): project configuration file used to save the project configuration information.
  4. Click Create. A project is created. The directory of a created project is organized as follows (for reference only).
    • AscendCL Project (C/C++):
      ├── Project name
      │   ├── build
      │   │    ├──cmake            // Directory of CMake dependencies.
      │   ├── out                    // Directory of executable files generated after build.
      │   ├── src
      │   │    ├── CMakeLists.txt   // Build script.
      │   │    ├── main.cpp         // Implementation file of the main function, which does not have code logic.
      │   ├── CMakeLists.txt        // Build script that calls the CMakeLists file in the src directory.
    • AscendCL Project (Python): No code directory is available.

Importing an Application Project

  1. You can import a project file in either of the following ways:
    • On the MindStudio welcome page, click Open, select the project to be imported, and click OK.
    • On the MindStudio project page, choose File > Open... from the top menu bar or click on the menu bar to select an existing project and open it.

      If a project has code risks, the trust window is displayed when you open the project.

      • If the project source code is trusted and secure, click Trust Project. (You can select Trust projects in <workspace_directory> to trust all projects in the directory.)
      • If the project is not trusted and you only want to view the source code, click Preview in Safe Mode to preview the project in safe mode.
      • To cancel opening the project, click Don't Open.
  2. If there is already an active project in the window, a confirmation message is displayed.
    • Click This Window to open the newly created project in the current window.
    • Click New Window to open the newly created project in a new window.
  3. After a project is imported, the project directory is displayed in a tree structure (subject to the actual result).

Creating a Sample Project

  1. Navigate to the project creation window.
    • On the MindStudio welcome page, click New Project.
    • On the MindStudio project page, choose File > New > Project... from the top menu bar.
  2. In the New Project window, select Ascend App and specify the project type. See Figure 3. (If the project type name is not completely displayed, hover the cursor on the name to display the complete name.)
    Figure 3 Sample project under AscendCL Samples

    CANN Version: indicates the activated CANN version. You can click Change on the right to change the CANN version. For details, see Switching/Activating a CANN Package.

    AscendCL C++ Samples and AscendCL Python Samples are sample projects developed based on AscendCL.

    If CANN is not configured in MindStudio, some application projects may not be properly displayed.

  3. Click Next. The corresponding code repository on Gitee is displayed.
  4. On the Gitee code repository page, choose Clone or Download > Copy to copy the download link of the code package.
  5. Run the git clone URL (URL is the copied download link of the code package) command in the development environment to clone the code package to the development environment.
    git clone https://gitee.com/ascend/samples.git
  6. Select the required sample from the downloaded folder and import it through MindStudio. For details, see Importing an Application Project.