Is an OpenGL Simulation Possible?

We are currently working on a project for one of our classes to parallelize boids with CUDA on NVIDIA GPUs. We were wondering if it was possible to run a visual simulation for a couple seconds using OpenGL? I noticed reading this post there may be some support for OpenGL or similar frameworks? If so if there any further guidance we can follow run our simulation.

It’s possible using the interactive apps on CARC OnDemand, which will use software rendering via Mesa (i.e., CPUs). They are currently not set up to use GPU hardware acceleration. The software rendering may be good enough though, and you will get the best performance using an epyc node.

Actually I think I’ve got the GPU rendering working now. Could you describe your application more? What software are you using? There are certain settings or command-line options that you would need to use in order to use the GPU for rendering.

It somewhat based on this: GitHub - LesleyLai/CUDA-flocking-boid

Our group doesn’t need it to be super performant we just need to use it to check if our simulation is running correctly.

Thank you for your response. We are developing a simulation for parallelizing boids using CUDA on NVIDIA GPUs, aimed at exploring flocking behaviors through visual simulations. Our project will use OpenGL to render the simulation output. We expect to use something like GLFW and GLEW for window management and OpenGL extension handling.

We integrate CUDA with OpenGL by employing CUDA graphics interop to share buffers, allowing CUDA to directly update positions that OpenGL then renders.

We are following the template from some previous projects but this is the general job.slurm we plan on using

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=16GB
#SBATCH --time=1:00:00
#SBATCH --partition=gpu 
#SBATCH --output=gpujob.out
#SBATCH --gres=gpu:a100:1

module purge
module load nvidia-hpc-sdk
module load gcc/8.3.0

You could try it out by going to CARC OnDemand > Interactive Apps > Desktop or Terminal GUI app, requesting a GPU, and once launched opening the terminal and running commands interactively like the following. Assuming you already have an executable named ParallelBoids or something like that, which generates the graphics.

For software rendering:

module purge
module load nvidia-hpc-sdk
module load gcc/8.3.0
./ParallelBoids

For GPU-accelerated rendering:

module purge
module load nvidia-hpc-sdk
module load gcc/8.3.0
vglrun +v -d egl ./ParallelBoids

The graphics should pop up in a new window.

Thank you so much for the help. I ended up having to add these modules and compilation in case anyone else is having trouble in the future.

module purge
module load nvidia-hpc-sdk
module load gcc/11.3.0 cuda/11.6.2 cmake gmake glew/2.2.0 freeglut/3.2.2 mesa/22.3.2 mesa-glu/9.0.2 

nvcc -o boids_simulation opengl_naive.cu -I$GLEW_ROOT/include -I$MESA_GLU_ROOT/include -I$MESA_ROOT/include -I$FREEGLUT_ROOT/include -L$GLEW_ROOT/lib64 -L$MESA_GLU_ROOT/lib -L$MESA_ROOT/lib -L$FREEGLUT_ROOT/lib64 -lglut -lGL -lGLEW -lGLU -lcudart -O2