Added CMakeLists as build framework

This commit is contained in:
Alejandro Saucedo 2020-08-24 07:52:06 +01:00
parent cfb81949db
commit bbc41aef12
11 changed files with 120 additions and 19 deletions

20
.gitignore vendored
View file

@ -176,3 +176,23 @@ bin/
external/boost/
tmp/
# CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles/
CMakeScripts
Testing
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
Makefile
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
Win32/
Debug/

35
CMakeLists.txt Normal file
View file

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.18.0)
project(kompute VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(Vulkan REQUIRED)
file(GLOB kompute_SRC
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/shaders/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/src/shaders/*.cpp"
)
add_executable(kompute
${kompute_SRC})
target_include_directories(
kompute PUBLIC
fmt
spdlog
Vulkan
)
target_link_libraries(
kompute
fmt::fmt
spdlog::spdlog
Vulkan::Vulkan
)

27
Makefile → MakefileKompute Normal file → Executable file
View file

@ -9,17 +9,25 @@ CF=~/Programming/lib/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-f
SCMP=/c/VulkanSDK/1.2.141.2/Bin32/glslangValidator.exe
####### Package manager #######
VCPKG=/c/Users/axsau/Programming/lib/vcpkg/vcpkg
####### Main Target Rules #######
run_cmake:
cmake \
-DCMAKE_TOOLCHAIN_FILE=C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
build: clean build_shaders
$(CC) \
src/* \
-w \
-std=c++17 \
-DDEBUG=1 \
-DRELEASE=1 \
-I"./external/" \
-I"C:\\VulkanSDK\\1.2.141.2\\Include\\" \
-L"C:\\VulkanSDK\\1.2.141.2\\Lib\\" \
-lvulkan-1 \
-o ./bin/main.exe
@ -30,6 +38,21 @@ build: clean build_shaders
#-g -fexceptions -fPIC \
#-static-libgcc -static-libstdc++ \
run_test:
$(CC) \
test/* \
-Wall \
-std=c++17 \
-DDEBUG=1 \
-DRELEASE=1 \
-I"./external/" \
-I"./src/" \
-L"C:\\VulkanSDK\\1.2.141.2\\Lib\\" \
-lvulkan-1 \
-o ./bin/test.exe && \
./bin/test.exe --success
build_linux:
g++ \
-g -shared-libgcc \
@ -45,7 +68,7 @@ build_shaders:
python scripts/convert_shaders.py \
--shader-path shaders/glsl \
--shader-binary $(SCMP) \
--header-path external/shaders \
--header-path src/shaders \
-v
docker_seldon_run:

View file

@ -2,7 +2,7 @@
## Principles
* Single header easy to import library to boost your Vulkan compute experience
* Single header easy to import library to boost your Vulkan compute experience (WIP)
* Non-vulkan naming convention to disambiguate Vulkan vs Kompute components
* Extends the existing vulkan API with a simpler compute-specific interface
* BYOV: Play nice with existing Vulkan applications with a bring-your-own-Vulkan design
@ -92,4 +92,6 @@ int main() {
## Development
Follows Mozilla C++ Style Guide https://www-archive.mozilla.org/hacking/mozilla-style-guide.html
* Follows Mozilla C++ Style Guide https://www-archive.mozilla.org/hacking/mozilla-style-guide.html
+ Uses post-commit hook to run the linter, you can set it up so it runs the linter before commit
* Uses vcpkg for finding the dependencies, it's the recommanded set up to retrieve the libraries

14
src/main.cpp Normal file → Executable file
View file

@ -11,7 +11,7 @@
#include <spdlog/spdlog.h>
// ranges.h must come after spdlog.h
#include <spdlog/fmt/bundled/ranges.h>
#include <fmt/ranges.h>
#include <vulkan/vulkan.h>
#include <vulkan/vulkan.hpp>
@ -39,18 +39,18 @@ main()
kp::Manager mgr;
spdlog::info("Creating first tensor");
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor( { 0.0, 1.0, 2.0 }) };
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor( { 0, 1, 2 }) };
mgr.evalOp<kp::OpCreateTensor>({ tensorLHS });
spdlog::info("Creating second tensor");
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
{ 2.0, 4.0, 6.0 }) };
{ 2, 4, 6 }) };
mgr.evalOp<kp::OpCreateTensor>({ tensorRHS });
// TODO: Add capabilities for just output tensor types
spdlog::info("Creating output tensor");
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
{ 0.0, 0.0, 0.0 }) };
{ 0, 0, 0 }) };
mgr.evalOp<kp::OpCreateTensor>({ tensorOutput });
spdlog::info("OpCreateTensor success for tensors");
@ -74,16 +74,16 @@ main()
spdlog::info("Creating first tensor");
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor(
{ 0.0, 1.0, 2.0 }) };
{ 0, 1, 2 }) };
spdlog::info("Creating second tensor");
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
{ 2.0, 4.0, 6.0 }) };
{ 2, 4, 6 }) };
// TODO: Add capabilities for just output tensor types
spdlog::info("Creating output tensor");
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
{ 0.0, 0.0, 0.0 }) };
{ 0, 0, 0 }) };
sq.record<kp::OpCreateTensor>({ tensorLHS });
sq.record<kp::OpCreateTensor>({ tensorRHS });

4
test/Main.cpp Normal file
View file

@ -0,0 +1,4 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"

View file

@ -1,8 +0,0 @@
#include "gtest/gtest.h"
#include "../src/Manager.hpp"
TEST(ManagerTest, ManagerEmptyInitTest) {
kp::Manager mgr;
mgr.~Manager();
}

25
test/TestTensor.cpp Normal file
View file

@ -0,0 +1,25 @@
#include <catch2/catch.hpp>
#include "Tensor.hpp"
int Factorial( int number ) {
return number <= 1 ? number : Factorial( number - 1 ) * number; // fail
// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass
}
TEST_CASE( "Factorial of 0 is 1 (fail)", "[single-file]" ) {
REQUIRE( Factorial(0) == 1 );
}
TEST_CASE( "Factorials of 1 and higher are computed (pass)", "[single-file]" ) {
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}
TEST_CASE("Exploring if manager test compiles") {
kp::Tensor tensor({0,1,2});
REQUIRE( tensor.size() == 3 );
}