Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a build script for vector_add #123

Merged
merged 6 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
endif()

set(SOURCE_FILES src/cu.cpp src/nvrtc.cpp)

include_directories(./include/)
include_directories(${CUDAToolkit_INCLUDE_DIRS})

add_library(cudawrappers SHARED ${SOURCE_FILES})

# Including linters rules
include(cmake/linter-tools.cmake)

# Tests
add_subdirectory(tests)
11 changes: 10 additions & 1 deletion README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,16 @@ where `<tool>` can be any of the following:

## Running the tests

:construction:
Enter the `build` directory and run `make test`.

If you are running the tests on DAS, you can run a job using `srun` command.
For instance,

```shell
srun -N 1 -C TitanX --gres=gpu:1 make test
```

abelsiqueira marked this conversation as resolved.
Show resolved Hide resolved
This command will run the tests in one of the worker nodes with a GPU device.

## Building the API documentation

Expand Down
8 changes: 8 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# vector_add
add_subdirectory(vector_add)

# This command will be executed from the test folder, which is where the .cu file must be located
add_custom_target(test
COMMAND vector_add/vector_add
DEPENDS vector_add
)
5 changes: 5 additions & 0 deletions tests/vector_add/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copies the kernel function to the tests folder
file(COPY vector_add_kernel.cu DESTINATION ..)
add_executable(vector_add EXCLUDE_FROM_ALL vector_add.cpp)
target_link_libraries(vector_add PRIVATE cudawrappers CUDA::cuda_driver
CUDA::nvrtc)
4 changes: 2 additions & 2 deletions tests/vector_add/vector_add.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <iostream>

#include "cu/cu.h"
#include "cu/nvrtc.h"
#include "cu.hpp"
#include "nvrtc.hpp"

void vector_add() {
int N = 1024;
Expand Down