Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions LBM/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
CUDA_PATH ?= /usr/local/cuda-12.9

ENZYME_PATH ?= $(HOME)/git/Reactant/enzyme/build/Enzyme/ClangEnzyme-22.so
CLANG_PATH ?= $(HOME)/git/llvm-project/build/bin/clang++
LIB_RAISE_PATH ?= $(HOME)/git/Enzyme-JAX/bazel-bin/libRaise.so
CLANG_PATH ?= $(HOME)/git/Enzyme/llvm-project/buildRelease/bin/clang++
LIB_RAISE_PATH ?= $(HOME)/git/Enzyme-JaX/bazel-bin/libRaise.so
REACTANT_EXTRA_PATH ?= $(HOME)/git/Reactant.jl/deps/ReactantExtra/bazel-bin/

export REACTANT_DEBUG=1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop debug output when no longer needed? (For some reason cannot suggest changes through github)

export PATH := $(CUDA_PATH)/bin:$(PATH)
export POLYGEIST_GPU_KERNEL_BLOCK_SIZE = 128
export LD_LIBRARY_PATH := $(REACTANT_EXTRA_PATH):$(LD_LIBRARY_PATH)

OPTIMIZE ?= yes
OPTIMIZE ?= no # yes

NEWCACHE ?= yes
AA ?= no
Expand All @@ -25,7 +26,7 @@ ABI ?= no
ALLOCATOR ?= no
VERIFY ?= no

DEBUG = no
DEBUG = yes
PROFILE = no
SM_VERSION = 120

Expand Down Expand Up @@ -56,8 +57,8 @@ LDFLAGS = -lcudart_static "-ldl" "-lrt" -lpthread -lm -L$(REACTANT_EXTRA_PATH) -

# Debug Flags
ifeq ($(DEBUG),yes)
CFLAGS += -g -G
LDFLAGS += -g -G
CFLAGS += -g
LDFLAGS += -g
endif

ifeq ($(ALLOCATOR),yes)
Expand Down Expand Up @@ -143,4 +144,4 @@ clean:
rm -rf $(program) *.o *.re_export

run: $(program)
./$(program) 10
./$(program) 10 -o out.txt
9 changes: 9 additions & 0 deletions LBM/lbm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <mcuda.h>
#endif

#include <errno.h>

#include <assert.h>

#define DFL1 (1.0f/ 3.0f)
#define DFL2 (1.0f/18.0f)
#define DFL3 (1.0f/36.0f)
Expand Down Expand Up @@ -393,6 +397,7 @@ void LBM_showGridStatistics( LBM_Grid grid ) {

static void storeValue( FILE* file, OUTPUT_PRECISION* v ) {
const int litteBigEndianTest = 1;
assert(file);
if( (*((unsigned char*) &litteBigEndianTest)) == 0 ) { /* big endian */
const char* vPtr = (char*) v;
char buffer[sizeof( OUTPUT_PRECISION )];
Expand All @@ -415,6 +420,10 @@ void LBM_storeVelocityField( LBM_Grid grid, const char* filename,
OUTPUT_PRECISION rho, ux, uy, uz;

FILE* file = fopen( filename, (binary ? "wb" : "w") );
if (!file) {
fprintf(stderr, "can't open %s: %s\n", filename, strerror(errno));
exit(1);
}

SWEEP_VAR
SWEEP_START(0,0,0,SIZE_X,SIZE_Y,SIZE_Z)
Expand Down
3 changes: 3 additions & 0 deletions LBM/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//#include <chrono>
#include <sys/time.h>
#include <sys/stat.h>
#include <assert.h>

/*############################################################################*/
static LBM_Grid CUDA_srcGrid, CUDA_dstGrid;
Expand Down Expand Up @@ -126,6 +127,7 @@ void MAIN_parseCommandLine( int nArgs, char* arg[], MAIN_Param* param, struct pb
else param->obstacleFilename = NULL;

param->resultFilename = params->outFile;
assert(param->resultFilename);
}

/*############################################################################*/
Expand Down Expand Up @@ -206,6 +208,7 @@ void MAIN_finalize( const MAIN_Param* param ) {
pb_SwitchToTimer(&timers, pb_TimerID_COMPUTE);
LBM_showGridStatistics( TEMP_srcGrid );

assert(param->resultFilename);
LBM_storeVelocityField( TEMP_srcGrid, param->resultFilename, TRUE );

LBM_freeGrid( (float**) &TEMP_srcGrid );
Expand Down