diff --git a/.gitignore b/.gitignore index 48c406d..698a114 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ data/ # Resulting images *.ppm + diff --git a/CMakeLists.txt b/CMakeLists.txt index 79cf298..192569c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/imgui) add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${IMGUI_FILES}) # CUDA has specific architectures - set it to the system's architecture if available (or 70 by default) -set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES 70) +set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES 52) set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON @@ -59,8 +59,8 @@ find_package(CUDA REQUIRED) include_directories("${CUDA_INCLUDE_DIRS}") # netcdf -find_package(netCDF REQUIRED) -message(STATUS "Found netcdf in ${GLFW3_INCLUDE_DIR}") +# find_package(netCDF REQUIRED) +# message(STATUS "Found netcdf in ${NETCDF_LIB}") execute_process( COMMAND nc-config --includedir @@ -74,9 +74,16 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) +execute_process( + COMMAND ncxx4-config --prefix + OUTPUT_VARIABLE NETCDFCXX_PREFIX_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + target_include_directories(cuda-raytracer PUBLIC ${netCDF_INCLUDE_DIR}) -find_library(NETCDF_LIB NAMES netcdf-cxx4 netcdf_c++4 PATHS ${NETCDFCXX_LIB_DIR} NO_DEFAULT_PATH) +find_library(NETCDF_LIB NAMES netcdf-cxx4 netcdf_c++4 PATHS ${NETCDFCXX_LIB_DIR} ${NETCDFCXX_PREFIX_DIR}/lib NO_DEFAULT_PATH) +message(STATUS "Found NetCDFCXX in ${NETCDF_LIB}") set(LIBS ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} GLAD ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${NETCDF_LIB}) diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..bcf23d9 --- /dev/null +++ b/default.nix @@ -0,0 +1,21 @@ +with import { config.allowUnfree = true; }; + +stdenv.mkDerivation { + name = "cuda-raytracer"; + src = ./.; + nativeBuildInputs = with cudaPackages; [cmake autoAddDriverRunpath autoPatchelfHook ]; + buildInputs = with pkgs; with cudaPackages; [ libGL glfw netcdf netcdfcxx4 cuda_nvcc cuda_cudart cuda_cccl libcurand]; + + postConfigure = '' + export netCDFCxx_DIR=${netcdfcxx4}/lib/cmake/netCDFCxx + ''; + + installTargets = "preinstall"; + + postInstall = '' + mkdir -p $out/bin + cp cuda-raytracer $out/bin + ''; + + LD_LIBRARY_PATH="/run/opengl-driver/lib/"; +} diff --git a/src/consts.cu b/src/consts.cu index 30e201f..0b953fe 100644 --- a/src/consts.cu +++ b/src/consts.cu @@ -1,9 +1,10 @@ #include "consts.h" +#include "cuda_error.h" // ----------------------- Colour mapping ----------------------- -__constant__ ColorStop d_stopsPythonLike[5]; -__constant__ ColorStop d_stopsGrayscale[2]; -__constant__ ColorStop d_stopsBluePurleRed[3]; +__device__ __constant__ ColorStop d_stopsPythonLike[5]; +__device__ __constant__ ColorStop d_stopsGrayscale[2]; +__device__ __constant__ ColorStop d_stopsBluePurleRed[3]; const ColorStop h_stopsPythonLike[] = { { 0.0f, Color3::init(0.2298057f, 0.29871797f, 0.75368315f) }, // Dark Blue @@ -37,8 +38,10 @@ Vec3 h_cameraUp = Vec3::init(0.0, 1.0, 0.0).normalize(); // Copy the above values to the device void copyConstantsToDevice() { + check_cuda_errors(cudaGetLastError()); // ----------------------- Colour mapping ----------------------- cudaMemcpyToSymbol(d_stopsPythonLike, h_stopsPythonLike, sizeof(h_stopsPythonLike)); + check_cuda_errors(cudaGetLastError()); cudaMemcpyToSymbol(d_stopsGrayscale, h_stopsGrayscale, sizeof(h_stopsGrayscale)); cudaMemcpyToSymbol(d_stopsBluePurleRed, h_stopsBluePurleRed, sizeof(h_stopsBluePurleRed)); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index dd15872..df722da 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -6,6 +6,7 @@ #include "Shader.h" #include "input/Widget.h" +#include "cuda_error.h" // TODO: Delete diff --git a/src/gui/Quad.cpp b/src/gui/Quad.cpp index d918763..5451a71 100644 --- a/src/gui/Quad.cpp +++ b/src/gui/Quad.cpp @@ -83,6 +83,7 @@ void Quad::cuda_init(float* data) { void Quad::render() { + check_cuda_errors(cudaGetLastError()); glBindTexture(GL_TEXTURE_2D, 0); this->renderer->render(); glBindTexture(GL_TEXTURE_2D, this->tex); diff --git a/src/gui/input/Widget.cpp b/src/gui/input/Widget.cpp index e57d9a1..dc47e8d 100644 --- a/src/gui/input/Widget.cpp +++ b/src/gui/input/Widget.cpp @@ -65,7 +65,7 @@ void Widget::tick(double fps) { this->renderOnce = true; } sprintf(this->fps, "%.3f fps\n", fps); - ImGui::Text(this->fps); + ImGui::Text("%s", this->fps); ImGui::End(); ImGui::Begin("Camera Controls"); diff --git a/src/illumination/Raycaster.cu b/src/illumination/Raycaster.cu index 400cce1..a0c108a 100644 --- a/src/illumination/Raycaster.cu +++ b/src/illumination/Raycaster.cu @@ -156,6 +156,8 @@ Raycaster::Raycaster(cudaGraphicsResource_t resources, int w, int h, float* data void Raycaster::render() { + std::cout << "hello???\n"; + check_cuda_errors(cudaGetLastError()); check_cuda_errors(cudaGraphicsMapResources(1, &this->resources)); check_cuda_errors(cudaGraphicsResourceGetMappedPointer((void**)&(this->fb->buffer), &(this->fb->buffer_size), resources)); diff --git a/src/main.cu b/src/main.cu index 6127861..d471ff2 100644 --- a/src/main.cu +++ b/src/main.cu @@ -21,7 +21,7 @@ static float* d_volume = nullptr; // * time controls - arbitrary skipping to specified point (would require some changes to gpubuffer) (could have) void getTemperature(std::vector& temperatureData, int idx = 0) { - std::string path = "data/trimmed"; + std::string path = "../../../hurricane-sandy-data"; // std::string path = "data"; std::string variable = "T"; DataReader dataReader(path, variable); @@ -31,7 +31,7 @@ void getTemperature(std::vector& temperatureData, int idx = 0) { } void getSpeed(std::vector& speedData, int idx = 0) { - std::string path = "data/trimmed"; + std::string path = "../../../hurricane-sandy-data"; // std::string path = "data"; std::string varU = "U"; std::string varV = "V";