Skip to content

Commit

Permalink
Merge pull request #123 from nlesc-recruit/116-vector-add
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira authored Mar 7, 2022
2 parents 17c7be8 + 27c050e commit 8145a61
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
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
```

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

0 comments on commit 8145a61

Please sign in to comment.