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

[WIP] document usage better #163

Merged
merged 4 commits into from
Apr 28, 2020
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: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
- name: Install Dependencies
run: sudo apt-get install doxygen
- name: Build
run: doxygen Doxyfile
run: make docs
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_BRANCH: master # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/html # The folder the action should deploy.
FOLDER: docs/ # The folder the action should deploy.
36 changes: 3 additions & 33 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROJECT_NAME = yacx - Yet Another CudaExecutor
PROJECT_NUMBER = 0.6.2
PROJECT_BRIEF = "wrapper to easily compile and execute cuda kernels"
PROJECT_LOGO =
OUTPUT_DIRECTORY = "docs"
OUTPUT_DIRECTORY = "docs/cpp"
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
Expand Down Expand Up @@ -122,49 +122,19 @@ FILE_PATTERNS = *.c \
*.cxx \
*.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.idl \
*.ddl \
*.odl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.cs \
*.d \
*.php \
*.php4 \
*.php5 \
*.phtml \
*.inc \
*.m \
*.markdown \
*.md \
*.mm \
*.dox \
*.py \
*.pyw \
*.f90 \
*.f95 \
*.f03 \
*.f08 \
*.f \
*.for \
*.tcl \
*.vhd \
*.vhdl \
*.ucf \
*.qsf \
*.ice
*.dox
RECURSIVE = YES
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = */jni/*
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = "examples"
EXAMPLE_PATTERNS = *
Expand Down
93 changes: 75 additions & 18 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ wrapper to easily compile and execute cuda kernels
- online compilation with NVRTC
- template kernels
- logging system
- simple to understand exceptions
- time kernel execution as well as uploading and downloading arguments to and from the device
- descriptive exceptions
- benchmarking
- time kernel execution as well as uploading and downloading arguments to and from the device

for more see the [changelog](./CHANGELOG.md)

## Requirements

- [Cuda Toolkit >= V7.0](https://developer.nvidia.com/cuda-toolkit)
- c++17 (just to build)
- [Cuda Toolkit >= V7.0 (recommended 9.3)](https://developer.nvidia.com/cuda-toolkit)
- C++17 (just to build)
- JDK >= 8 (to build the JNI)

## Usage
## C++

### Usage

```c++
// file.cpp
#include "yacx/main.hpp"
#include <algorithm>
#include <experimental/iterator>
Expand Down Expand Up @@ -85,7 +90,7 @@ int main() {
}
```

### Compile
#### Compile

download the latest version of the library from the [releases](https://github.com/ZerataX/yacx/releases/latest) section or build it yourself:

Expand All @@ -98,21 +103,15 @@ make -C build yacx-jni

and then compile with:
```console
g++ -Wall -Wextra --pedantic -lyacx -lnvrtc -lcuda -L $(CUDA_PATH)/lib64 -Wl,-rpath,$(CUDA_PATH)/lib64 file.cpp
g++ -lyacx -lnvrtc -lcuda -L $(CUDA_PATH)/lib64 -Wl,-rpath,$(CUDA_PATH)/lib64 file.cpp
```

some syntatic sugar is given using templates, which requires you to include the headers when building:
```console
g++ -Wall -Wextra --pedantic -lyacx -lnvrtc -lcuda -L $(CUDA_PATH)/lib64 -Wl,-rpath,$(CUDA_PATH)/lib64 -I include/yacx file.cpp
```

## Examples

yacx comes with many examples using a multitude of different kernels with hostcode in c++,java and scala

### C++

#### Run Examples
### Run Examples

```console
# list examples
Expand All @@ -123,22 +122,80 @@ examples/example_saxpy.cpp
examples/example_program.cpp
examples/example_gauss.cpp
# compile example
$ make example_program
$ cmake -H. -Bbuild
$ make -C build example_program
# run example
$ make run
$ ./build/examples/bin/example_program
1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8
```

## Tests
### Tests

Require the [Catch2](https://github.com/catchorg/Catch2) test-framework

```console
$ make check
$ cmake -H. -Bbuild
$ make -C build tests
$ pushd build/test/bin/
$ ./tests
$ popd
```

For more info read the [contribution guideline](https://github.com/ZerataX/yacx/blob/master/CONTRIBUTING.md#test)

## Java

### Run Examples

```console
# for autocompletion
$ source yacx-completion.bash
# compile example
$ ./yacx build-java
# list examples
$ ./yacx execute-java
!! parameter needed, select one of the following
ExampleSimpleGEMMBenchmark
ExampleFastGEMM
ExampleSimpleGEMM
...
$ ./yacx.sh execute-java ExampleFastGEMM
```

### Tests

```console
# build JNI and Test Classes
$ cmake -H. -Bbuild
$ make -C build JNITestClasses
# link kernels to execution folder
$ mkdir build/java/bin/examples
$ ln -s $(realpath examples/kernels/) build/java/bin/examples/kernels
# execute tests
$ pushd build/java/bin
$ java -Djava.library.path=../../ -jar src/junit-platform-console-standalone-1.5.2.jar --class-path . --scan-class-path
$ popd
```

## Scala

### Run Examples

```console
# for autocompletion
$ source yacx-completion.bash
# compile example
$ ./yacx build-scala
# list examples
$ ./yacx execute-scala
!! parameter needed, select one of the following
ExampleFilterBenchmark
ExampleFilter
ExampleFastGEMM
...
$ ./yacx.sh execute-scala ExampleFastGEMM
```

## Contributing

Make sure you agree to the [code of conduct](./CODE_OF_CONDUCT.md) and read the [contribution guideline](https://github.com/ZerataX/yacx/blob/master/CONTRIBUTING.md)
Expand Down
25 changes: 0 additions & 25 deletions examples/makefile

This file was deleted.

56 changes: 7 additions & 49 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CC := g++ # This is the main compiler
# CC := clang --analyze # and comment out the linker last line for sanity
ANALYZER := clang --analyze
LINTER := cpplint
FORMATER := clang-format
MKDIR_P = mkdir -p
Expand All @@ -10,75 +9,34 @@ VENDOR := exclude
TESTDIR := test
BUILDDIR := build
EXAMPLEDIR := examples
TARGET := bin/runner
TESTTARGET := bin/tester
DIRS := bin build
DIRS := ${BUILDDIR}

SRCEXT := cpp
HEADDEREXT := hpp
SOURCES := $(shell find $(SRCDIR) -maxdepth 1 -type f -name '*.$(SRCEXT)')
TESTS := $(shell find $(TESTDIR) -type f -name '*.$(SRCEXT)')
EXAMPLES := $(shell find $(EXAMPLEDIR) -maxdepth 1 -type f -name '*.$(SRCEXT)')
HEADERS := $(shell find $(LIBDIR) -type f -name '*.$(HEADDEREXT)')
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
TEST_OBJ = $(OBJECTS) $(patsubst $(TESTDIR)/%,$(BUILDDIR)/%,$(TESTS:.$(SRCEXT)=.o))
CFLAGS := -std=c++17 -Wall -g -DNVRTC_GET_TYPE_NAME=1
LIB := -lnvrtc -lcuda -L $(CUDA_PATH)/lib64 -Wl,-rpath,$(CUDA_PATH)/lib64
INC := -I $(INCDIR) -I $(CUDA_PATH)/include

# Build
example_program: example
@echo " $(CC) build/example_program.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_program.o $(OBJECTS) -o $(TARGET) $(LIB)
example_template: example
echo " $(CC) build/example_template.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_template.o $(OBJECTS) -o $(TARGET) $(LIB)
example_saxpy: example
@echo " $(CC) build/example_saxpy.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_saxpy.o $(OBJECTS) -o $(TARGET) $(LIB)
example_matrix_multiply: example
@echo " $(CC) build/example_matrix_multiply.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_matrix_multiply.o $(OBJECTS) -o $(TARGET) $(LIB)
example_gauss: example
@echo " $(CC) build/example_gauss.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_gauss.o $(OBJECTS) -o $(TARGET) $(LIB)
example_logger: example
@echo " $(CC) build/example_logger.o $(OBJECTS) -o $(TARGET) $(LIB)"; $(CC) build/example_logger.o $(OBJECTS) -o $(TARGET) $(LIB)
example: directories $(OBJECTS)
+$(MAKE) -C examples

directories: ${DIRS}

${DIRS}:
${MKDIR_P} ${DIRS}

$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<

clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)

@echo " $(RM) -r $(DIRS) docs/{java,html,latex}"; $(RM) -r $(DIRS) docs/{java,html,latex}

# Execute
run:
@$(TARGET)

# Format
format:
$(FORMATER) -i -style=file $(SOURCES) $(HEADERS) $(TESTS) $(EXAMPLES)

# Linter
lint:
$(LINTER) --root=${CURDIR} --recursive .
#clang-tidy src/ -system-headers=false

# Tests
init_submodules:
-git submodule update --init --recursive

${TESTTARGET}: init_submodules directories $(OBJECTS)
+$(MAKE) -C test
@echo " Linking... $(TEST_OBJ)";
@echo " $(CC) $(TEST_OBJ) -o $(TESTTARGET) $(LIB)"; $(CC) $(TEST_OBJ) -o $(TESTTARGET) $(LIB)

check: $(TESTTARGET)
@$(TESTTARGET) -d yes
docs:
doxygen Doxyfile
javadoc -d docs/java -sourcepath src/main/java yacx

.PHONY: clean, lint, directories, format, init_submodules, check, run
.PHONY: clean, lint, directories, format, docs

15 changes: 8 additions & 7 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ let fhs = pkgs.buildFHSUserEnv {
gnupg
autoconf
curl
cmake
cmake
doxygen
procps
gnumake
gcc7
Expand All @@ -20,11 +21,11 @@ let fhs = pkgs.buildFHSUserEnv {
linuxPackages.nvidia_x11
libGLU
libGL
xorg.libXi xorg.libXmu freeglut
xorg.libXi xorg.libXmu freeglut
xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib
ncurses5
stdenv.cc
binutils
ncurses5
stdenv.cc
binutils
jdk12
];
multiPkgs = pkgs: with pkgs; [ zlib ];
Expand All @@ -34,8 +35,8 @@ let fhs = pkgs.buildFHSUserEnv {
export JAVA_HOME=${pkgs.jdk12.home}
export PATH=$CUDA_PATH/bin:$PATH
# export LD_LIBRARY_PATH=${pkgs.linuxPackages.nvidia_x11}/lib
export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
export EXTRA_CCFLAGS="-I/usr/include"
export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
export EXTRA_CCFLAGS="-I/usr/include"
'';
};
in pkgs.stdenv.mkDerivation {
Expand Down
Loading