Skip to content

Commit

Permalink
fixed shared memory kernel
Browse files Browse the repository at this point in the history
- shared memory kernel now works
- separate factor and solve stages for the lu solver
- added adaptive backend testing based on the backends that were compiled
  • Loading branch information
samayala22 committed Feb 20, 2024
1 parent b1c1c1c commit 096b8ea
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 225 deletions.
2 changes: 1 addition & 1 deletion tests/test_linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main(int argc, char **argv) {
const float b = 5.0f; // half wing span

const std::vector<std::string> meshes = {"../../../../mesh/elliptic_64x64.x"};
const std::vector<std::string> backends = {"cpu"};
const std::vector<std::string> backends = get_available_backends();
std::vector<f32> test_alphas = {0, 1, 2, 3, 4, 5, 10, 15};
std::transform(test_alphas.begin(), test_alphas.end(), test_alphas.begin(), to_radians);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_non_linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void write_vector_pair(const std::string& filename, const std::vector<T>& vec1,

int main(int argc, char** argv) {
const std::vector<std::string> meshes = {"../../../../mesh/infinite_rectangular_5x200.x"};
const std::vector<std::string> backends = {"cpu"};
const std::vector<std::string> backends = get_available_backends();
std::vector<std::pair<std::string, std::unique_ptr<LiftCurveFunctor>>> lift_curves;
lift_curves.emplace_back(std::make_pair("spallart1", std::make_unique<SpallartLiftCurve>(1.2f, 0.28f, 0.02f, 2.f*PI_f, 2.f*PI_f)));
lift_curves.emplace_back(std::make_pair("spallart2", std::make_unique<SpallartLiftCurve>(0.72f, 0.28f, 0.04f, 2.f*PI_f, 1.5f*PI_f)));
Expand Down
4 changes: 4 additions & 0 deletions vlm/backends/cuda/include/vlm_backend_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class BackendCUDA : public Backend {
float* d_rhs = nullptr;
float* d_gamma = nullptr;
float* d_delta_gamma = nullptr;

int* d_solver_info = nullptr;
int* d_solver_ipiv = nullptr;
float* d_solver_buffer = nullptr;

MeshProxy h_mesh;
MeshProxy* d_mesh;
Expand Down
293 changes: 72 additions & 221 deletions vlm/backends/cuda/src/vlm_backend_cuda.cu

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vlm/backends/cuda/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target("backend-cuda")
set_default(false)
add_packages("cuda")
add_deps("backend-cpu")

add_cuflags("-lineinfo")
add_includedirs("../../include")
add_files("src/*.cu")
add_includedirs("include", {public = true})
3 changes: 2 additions & 1 deletion vlm/include/vlm_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class Backend {
};

std::unique_ptr<Backend> create_backend(const std::string& backend_name, Mesh& mesh);
std::vector<std::string> get_available_backends();

}
} // namespace vlm
11 changes: 11 additions & 0 deletions vlm/src/vlm_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,15 @@ std::unique_ptr<Backend> vlm::create_backend(const std::string& backend_name, Me
}
#endif
throw std::runtime_error("Unsupported backend: " + backend_name);
}

std::vector<std::string> vlm::get_available_backends() {
std::vector<std::string> backends;
#ifdef VLM_CPU
backends.push_back("cpu");
#endif
#ifdef VLM_CUDA
backends.push_back("cuda");
#endif
return backends;
}

0 comments on commit 096b8ea

Please sign in to comment.