Skip to content

Commit

Permalink
[test]: Remove unit testing for now
Browse files Browse the repository at this point in the history
Need to find a way to CUDA unit test.
  • Loading branch information
cszach committed Dec 29, 2023
1 parent 4379a98 commit 2135d97
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 187 deletions.
31 changes: 0 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0135 NEW)

project(Raydiance LANGUAGES CXX CUDA)

Expand Down Expand Up @@ -54,33 +53,3 @@ add_executable(demo src/main.cu)
target_link_libraries(demo PUBLIC raydiance)

set_target_properties(demo PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_ARCHITECTURES "86")

# Google Test setup

include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Google Test

enable_testing()

add_executable(
raydiance_test
test/main.cpp
)
target_link_libraries(
raydiance_test
raydiance
GTest::gtest_main
)

set_target_properties(raydiance_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_ARCHITECTURES "86")

include(GoogleTest)
gtest_discover_tests(raydiance_test)
3 changes: 1 addition & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh

cmake -B build . && \
cmake --build build && \
cd build && ctest
cmake --build build
48 changes: 23 additions & 25 deletions include/math/Vec3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,62 @@ class Vec3 {
float y;
float z;

__host__ __device__ Vec3();
__host__ __device__ Vec3(float x, float y, float z);
__device__ Vec3();
__device__ Vec3(float x, float y, float z);

__host__ __device__ void set(float x, float y, float z);
__device__ void set(float x, float y, float z);

__host__ __device__ float length() const;
__host__ __device__ float lengthSquared() const;
__host__ __device__ bool equals(const Vec3 &v) const;
__device__ float length() const;
__device__ float lengthSquared() const;
__device__ bool equals(const Vec3 &v) const;

__host__ __device__ Vec3 operator-() const;
__host__ __device__ Vec3 &operator+=(const Vec3 &v);
__host__ __device__ Vec3 &operator-=(const Vec3 &v);
__host__ __device__ Vec3 &operator*=(const Vec3 &v);
__host__ __device__ Vec3 &operator/=(const float t);
__device__ Vec3 operator-() const;
__device__ Vec3 &operator+=(const Vec3 &v);
__device__ Vec3 &operator-=(const Vec3 &v);
__device__ Vec3 &operator*=(const Vec3 &v);
__device__ Vec3 &operator/=(const float t);

__host__ __device__ Vec3 normalize() const;
__host__ __device__ float dot(const Vec3 &v) const;
__host__ __device__ Vec3 cross(const Vec3 &v) const;
__device__ Vec3 normalize() const;
__device__ float dot(const Vec3 &v) const;
__device__ Vec3 cross(const Vec3 &v) const;

__device__ static Vec3 randomInUnitSphere(curandState *local_rand_state);
__device__ static Vec3 randomUnit(curandState *local_rand_state);
};

__host__ __device__ inline Vec3 operator+(const Vec3 &u, const Vec3 &v) {
__device__ inline Vec3 operator+(const Vec3 &u, const Vec3 &v) {
return Vec3(u.x + v.x, u.y + v.y, u.z + v.z);
}

__host__ __device__ inline Vec3 operator-(const Vec3 &u, const Vec3 &v) {
__device__ inline Vec3 operator-(const Vec3 &u, const Vec3 &v) {
return Vec3(u.x - v.x, u.y - v.y, u.z - v.z);
}

__host__ __device__ inline Vec3 operator*(const Vec3 &u, const Vec3 &v) {
__device__ inline Vec3 operator*(const Vec3 &u, const Vec3 &v) {
return Vec3(u.x * v.x, u.y * v.y, u.z * v.z);
}

__host__ __device__ inline Vec3 operator*(const Vec3 &v, const float t) {
__device__ inline Vec3 operator*(const Vec3 &v, const float t) {
return Vec3(v.x * t, v.y * t, v.z * t);
}

__host__ __device__ inline Vec3 operator*(const float t, const Vec3 &v) {
return v * t;
}
__device__ inline Vec3 operator*(const float t, const Vec3 &v) { return v * t; }

__host__ __device__ inline Vec3 operator/(const Vec3 &v, const float t) {
__device__ inline Vec3 operator/(const Vec3 &v, const float t) {
return v * (1 / t);
}

__host__ __device__ inline Vec3 Vec3::normalize() const {
__device__ inline Vec3 Vec3::normalize() const {
float l = length();

return Vec3(x / l, y / l, z / l);
}

__host__ __device__ inline float Vec3::dot(const Vec3 &v) const {
__device__ inline float Vec3::dot(const Vec3 &v) const {
return x * v.x + y * v.y + z * v.z;
}

__host__ __device__ inline Vec3 Vec3::cross(const Vec3 &v) const {
__device__ inline Vec3 Vec3::cross(const Vec3 &v) const {
return Vec3(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
}

Expand Down
8 changes: 8 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if [ -x ./build/bin/demo ]
then
./build/bin/demo
else
>&2 echo "No executable found."
fi
24 changes: 11 additions & 13 deletions src/math/Vec3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,48 @@

#include <cmath>

__host__ __device__ Vec3::Vec3() : x(0), y(0), z(0) {}
__host__ __device__ Vec3::Vec3(float x, float y, float z) : x(x), y(y), z(z) {}
__device__ Vec3::Vec3() : x(0), y(0), z(0) {}
__device__ Vec3::Vec3(float x, float y, float z) : x(x), y(y), z(z) {}

__host__ __device__ void Vec3::set(float x, float y, float z) {
__device__ void Vec3::set(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
}

__host__ __device__ float Vec3::length() const { return sqrt(lengthSquared()); }
__host__ __device__ float Vec3::lengthSquared() const {
return x * x + y * y + z * z;
}
__host__ __device__ bool Vec3::equals(const Vec3 &v) const {
__device__ float Vec3::length() const { return sqrt(lengthSquared()); }
__device__ float Vec3::lengthSquared() const { return x * x + y * y + z * z; }
__device__ bool Vec3::equals(const Vec3 &v) const {
return x == v.x && y == v.y && z == v.z;
}

__host__ __device__ Vec3 Vec3::operator-() const { return Vec3(-x, -y, -z); }
__device__ Vec3 Vec3::operator-() const { return Vec3(-x, -y, -z); }

__host__ __device__ Vec3 &Vec3::operator+=(const Vec3 &v) {
__device__ Vec3 &Vec3::operator+=(const Vec3 &v) {
x += v.x;
y += v.y;
z += v.z;

return *this;
}

__host__ __device__ Vec3 &Vec3::operator-=(const Vec3 &v) {
__device__ Vec3 &Vec3::operator-=(const Vec3 &v) {
x -= v.x;
y -= v.y;
z -= v.z;

return *this;
}

__host__ __device__ Vec3 &Vec3::operator*=(const Vec3 &v) {
__device__ Vec3 &Vec3::operator*=(const Vec3 &v) {
x *= v.x;
y *= v.y;
z *= v.z;

return *this;
}

__host__ __device__ Vec3 &Vec3::operator/=(const float t) {
__device__ Vec3 &Vec3::operator/=(const float t) {
x /= t;
y /= t;
z /= t;
Expand Down
9 changes: 0 additions & 9 deletions test/main.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions test/math/RayTest.hpp

This file was deleted.

76 changes: 0 additions & 76 deletions test/math/Vec3Test.hpp

This file was deleted.

0 comments on commit 2135d97

Please sign in to comment.