forked from CIS565-Fall-2015/Project0-CUDA-Getting-Started
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f458457
Showing
37 changed files
with
31,325 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>cis565</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> | ||
<triggers>clean,full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> | ||
<triggers>full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.cdt.core.cnature</nature> | ||
<nature>org.eclipse.cdt.core.ccnature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
project(cis565_getting_started) | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
|
||
# Set up include and lib paths | ||
set(EXTERNAL "external") | ||
include_directories("${EXTERNAL}/include") | ||
include_directories("${EXTERNAL}/src") | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(EXTERNAL_LIB_PATH "${EXTERNAL}/lib/osx") | ||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
set(EXTERNAL_LIB_PATH "${EXTERNAL}/lib/linux" "/usr/lib64") | ||
elseif(WIN32) | ||
set(EXTERNAL_LIB_PATH "${EXTERNAL}/lib/win") | ||
endif() | ||
link_directories(${EXTERNAL_LIB_PATH}) | ||
list(APPEND CMAKE_LIBRARY_PATH "${EXTERNAL_LIB_PATH}") | ||
|
||
# Find up and set up core dependency libs | ||
|
||
set(GLFW_INCLUDE_DIR "${EXTERNAL}/include") | ||
set(GLFW_LIBRARY_DIR "${CMAKE_LIBRARY_PATH}") | ||
find_library(GLFW_LIBRARY "glfw3" HINTS "${GLFW_LIBRARY_DIR}") | ||
|
||
set(GLEW_INCLUDE_DIR "${EXTERNAL}/include") | ||
set(GLEW_LIBRARY_DIR "${CMAKE_LIBRARY_PATH}") | ||
add_definitions(-DGLEW_STATIC) | ||
find_package(GLEW) | ||
|
||
find_package(OpenGL) | ||
|
||
set(CORELIBS | ||
"${GLFW_LIBRARY}" | ||
"${OPENGL_LIBRARY}" | ||
"${GLEW_LIBRARY}" | ||
) | ||
|
||
# Compiler flags | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
# OSX-specific hacks/fixes | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
list(APPEND CORELIBS "-framework IOKit") | ||
list(APPEND CORELIBS "-framework Cocoa") | ||
list(APPEND CORELIBS "-framework CoreVideo") | ||
# Use C++11 | ||
add_compile_options(-std=c++11) | ||
list(APPEND CUDA_NVCC_FLAGS "-std=c++11") | ||
# Link against libstdc++ since CUDA doesn't support libc++ yet | ||
add_compile_options(-stdlib=libstdc++) | ||
list(APPEND CMAKE_EXE_LINKER_FLAGS "-stdlib=libstdc++") | ||
list(APPEND CUDA_NVCC_FLAGS "--compiler-options;-stdlib=libstdc++") | ||
endif() | ||
|
||
# Linux-specific hacks/fixes | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
list(APPEND CMAKE_EXE_LINKER_FLAGS "-lX11 -lXxf86vm -lXrandr -lpthread -lXi") | ||
endif() | ||
|
||
# Crucial magic for CUDA linking | ||
find_package(Threads REQUIRED) | ||
find_package(CUDA REQUIRED) | ||
|
||
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE ON) | ||
set(CUDA_SEPARABLE_COMPILATION ON) | ||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(CUDA_PROPAGATE_HOST_FLAGS OFF) | ||
endif() | ||
|
||
add_subdirectory(src) | ||
|
||
cuda_add_executable(${CMAKE_PROJECT_NAME} | ||
"src/main.hpp" | ||
"src/main.cpp" | ||
) | ||
|
||
target_link_libraries(${CMAKE_PROJECT_NAME} | ||
src | ||
${CORELIBS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
Project 0: CUDA Getting Started | ||
=============================== | ||
|
||
CIS 565: GPU Programming | ||
|
||
* TODO: YOUR NAME HERE | ||
|
||
Final performance and testing done on: | ||
|
||
* TODO: i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab) | ||
|
||
### TODO: Your README | ||
|
||
(Remember, this is public, so don't put anything here that you don't want to | ||
share with the world.) | ||
|
||
|
||
Instructions | ||
============ | ||
|
||
**TODO (later): remove all of these instructions**, so that your README | ||
represents your own project. You can always read the instructions on the | ||
original GitHub page. | ||
|
||
This project (and all other CUDA projects in this course) requires an NVIDIA | ||
graphics card with CUDA capability! Any card with Compute Capability 2.0 (sm_20) | ||
or greater will work. Gheck your GPU on this [compatibility table](https://developer.nvidia.com/cuda-gpus). | ||
If you do not have a personal machine with these specs, you may use | ||
computers in the SIG Lab *or* machines 1-5 in Moore 100B. | ||
|
||
**HOWEVER**: If you need to use the lab computer for your development, you will | ||
not presently be able to do GPU performance profiling. This will be very | ||
important for debugging performance bottlenecks in your program. If you do not | ||
have administrative access to a CUDA-capable machine, please email the TA as | ||
soon as possible to find a solution. | ||
|
||
|
||
## Part 1: Setting up your development environment | ||
|
||
Skip if you are developing on a lab computer. | ||
|
||
### Windows | ||
|
||
1. Make sure you are running Windows 7/8/10 and that your NVIDIA drivers are | ||
up-to-date. You will need support for OpenGL 4.0 or better in this class. | ||
2. Install Visual Studio 2013 (**not** 2015). | ||
* 2010/2012 will also work, if you already have one installed. | ||
* http://www.seas.upenn.edu/cets/software/msdn/ | ||
* You need C++ support. None of the optional components should be necessary. | ||
3. Install [CUDA 7](https://developer.nvidia.com/cuda-downloads?sid=925343). | ||
* You can use the express installation. Make sure you get Nsight for Visual | ||
Studio. | ||
4. Install [CMake](http://www.cmake.org/download/). | ||
5. Install [Git](https://git-scm.com/download/win). | ||
|
||
### OS X | ||
|
||
1. Make sure you are running OS X 10.9 or newer. | ||
2. Install XCode (available for free from the App Store). | ||
* On 10.10, this may not actually be necessary. Try running `gcc` | ||
in a terminal first. | ||
3. Install OS X Unix Command Line Development Tools (if necessary). | ||
4. Install [CUDA 7](https://developer.nvidia.com/cuda-downloads?sid=925343) | ||
(don't use cask; the CUDA cask is outdated). | ||
* Make sure you get Nsight. | ||
5. Install [Git](https://git-scm.com/download/mac) | ||
(or: `brew install git`). | ||
6. Install [CMake](http://www.cmake.org/download/) | ||
(or: `brew cask install cmake`). | ||
|
||
### Linux | ||
|
||
Note: to debug CUDA on Linux, you will need an NVIDIA GPU with Compute | ||
Capability 5.0. | ||
|
||
1. Install [CUDA 7](https://developer.nvidia.com/cuda-downloads?sid=925343). | ||
* Make sure you get Nsight. | ||
2. Install Git (`apt-get install git` on Debian/Ubuntu). | ||
3. Install CMake (`apt-get install cmake` on Debian/Ubuntu). | ||
|
||
|
||
## Part 2: Fork & Clone | ||
|
||
1. Use GitHub to fork this repository into your own GitHub account. | ||
2. If you haven't used Git, you'll need to set up a few things. | ||
* On Windows: In order to use Git commands, you can use Git Bash. You can | ||
right-click in a folder and open Git Bash there. | ||
* On OS X/Linux: Open a terminal. | ||
* Configure git with some basic options by running these commands: | ||
* `git config --global push.default simple` | ||
* `git config --global user.name "YOUR NAME"` | ||
* `git config --global user.email "[email protected]"` | ||
* (Or, you can use your own address, but remember that it will be public!) | ||
3. Clone from GitHub onto your machine: | ||
* Navigate to the directory where you want to keep your 565 projects, then | ||
clone your fork. | ||
* `git clone` the clone URL from your GitHub fork homepage. | ||
|
||
* [How to use GitHub](https://guides.github.com/activities/hello-world/) | ||
* [How to use Git](http://git-scm.com/docs/gittutorial) | ||
|
||
|
||
## Part 3: Build & Run | ||
|
||
Project 0 is a simple program that demonstrates CUDA and OpenGL functionality | ||
and interoperability, testing that CUDA has been properly installed. If the | ||
machine you are working on has CUDA and OpenGL 4.0 support, then when you run | ||
the program, you should see either one or two colors. The colors depend on your | ||
graphics card, so you'll probably get different results than other students. | ||
|
||
* `src/` contains the source code. | ||
* `external/` contains the binaries and headers for GLEW and GLFW. | ||
|
||
**CMake note:** Do not change any build settings or add any files to your | ||
project directly (in Visual Studio, Nsight, etc.) Instead, edit the | ||
`src/CMakeLists.txt` file. Any files you add must be added here. If you edit it, | ||
just rebuild your VS/Nsight project to make it update itself. | ||
|
||
### Windows | ||
|
||
1. In Git Bash, navigate to your cloned project directory. | ||
2. Create a `build` directory: `mkdir build` | ||
* (This "out-of-source" build makes it easy to delete the `build` directory | ||
and try again if something goes wrong with the configuration.) | ||
3. Navigate into that directory: `cd build` | ||
4. Open the CMake GUI to configure the project: | ||
* `cmake-gui ..` | ||
* or: "C:\Program Files (x86)\cmake\bin\cmake-gui.exe" .. | ||
* Click *Configure*. Select your version of Visual Studio, Win64. | ||
(**NOTE:** you must use Win64, as we don't provide libraries for Win32.) | ||
* If you see an error like `CUDA_SDK_ROOT_DIR-NOTFOUND`, | ||
set `CUDA_SDK_ROOT_DIR` to your CUDA install path. This will be something | ||
like: `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.0` | ||
* Click *Generate*. | ||
5. If generation was successful, there should now be a Visual Studio solution | ||
(`.sln`) file in the `build` directory that you just created. Open this. | ||
(from the command line: `explorer *.sln`) | ||
6. Build. (Note that there are Debug and Release configuration options.) | ||
7. Run. Make sure you run the `cis565_` target (not `ALL_BUILD`) by | ||
right-clicking it and selecting "Set as StartUp Project". | ||
|
||
### OS X & Linux | ||
|
||
It is recommended that you use Nsight. | ||
|
||
1. In a terminal, navigate to your cloned project directory | ||
(`cd some/path`). | ||
2. Create a `build` directory: `mkdir build` | ||
* (This "out-of-source" build makes it easy to delete the `build` directory | ||
and try again if something goes wrong with the configuration.) | ||
3. Navigate into that directory: `cd build` | ||
4. Open the CMake GUI to configure the project: `cmake-gui ..` | ||
* Click *Configure*. Select the Unix Makefiles generator. | ||
* If you see an error like `CUDA_SDK_ROOT_DIR-NOTFOUND`, | ||
set `CUDA_SDK_ROOT_DIR` to your CUDA install path. This will be something | ||
like: `/usr/local/cuda` | ||
* Click *Generate*. | ||
5. Open Nsight. Set the workspace to the one *containing* your cloned repo. | ||
6. *File->Import...->General->Existing Projects Into Workspace*. Select | ||
the project directory. *Finish.* | ||
7. Select the *cis565-* project in the Project Explorer. Build. | ||
8. Run. | ||
|
||
|
||
## Part 4: Modify | ||
|
||
1. Search the code for `TODO`: you'll find one in `src/main.cpp` on line 13. | ||
Change the string to your name, rebuild, and run. | ||
(`m_yourName = "TODO: YOUR NAME HERE";`) | ||
2. Take a screenshot of the window (including title bar) and save it to the | ||
`images` directory for Part 6. | ||
3. You're done with some code changes now; make a commit! | ||
* Make sure to `git add` the `main.cpp` file. | ||
* Use `git status` to make sure you didn't miss anything. | ||
* Use `git commit` to save a version of your code including your changes. | ||
* Use `git push` to sync your code history to the GitHub server. | ||
|
||
## Part 5: Analyze | ||
|
||
**NOTE: This part *cannot* be done on the lab computers, as it requires | ||
administrative access.** If you do not have a CUDA-capable computer of your | ||
own, you may need to borrow one for this part. However, you can still do the | ||
rest of your development on the lab computer. | ||
|
||
### Windows | ||
|
||
1. Go to the Nsight menu in Visual Studio. | ||
2. Select *Start Performance Analysis...*. | ||
3. Select *Trace Application*. | ||
4. Under *Application Control*, click *Launch*. | ||
5. Run the program for a few seconds, then close it. | ||
6. At the top of the report page, select *Timeline* from the drop-down menu. | ||
7. Take a screenshot of this tab and save it to `images`, for Part 6. | ||
|
||
### OS X & Linux | ||
|
||
1. Open your project in Nsight. | ||
2. *Run*->*Profile*. | ||
3. Run the program for a few seconds, then close it. | ||
4. Take a screenshot of the timeline and save it to `images`, for Part 6. | ||
|
||
|
||
## Part 6: Write & Submit | ||
|
||
1. Update ALL of the TODOs at the top of this README: | ||
* Remove all instructions. (You can always read them on the original | ||
GitHub repository.) | ||
* Add your name, computer, and whether it's a personal or lab computer. | ||
* Embed the screenshots you took. | ||
* Syntax help: https://help.github.com/articles/writing-on-github/ | ||
2. Add, commit, and push your screenshots and README. | ||
* Make sure your README looks good on GitHub! | ||
3. If you have modified either of the `CMakeLists.txt` at all (aside from | ||
the list of `SOURCE_FILES`), you **must** test your project in Moore 100B. | ||
4. Open a GitHub pull request so that we can see that you have finished. | ||
5. Send an email to the TA (gmail: kainino1+cis565@) with: | ||
* **Subject**: in the form of `[CIS565] Project 0: PENNKEY` | ||
* Direct link to YOUR fork on GitHub | ||
* Feedback on the project itself, if any. | ||
|
||
And you're done! |
Oops, something went wrong.