From c8da051f32d9bb8ef8a54688760ba1f10c51bf93 Mon Sep 17 00:00:00 2001 From: Anton Ljungdahl Date: Thu, 17 Oct 2024 22:45:10 +0200 Subject: [PATCH] log refactor, before doing atomphys stuff probably --- .gitignore | 1 + build.bat | 8 ++++++-- src/main.c | 34 +++++++++++++++++----------------- src/test_mkl.c | 20 ++++++++++---------- timeBuild.ctm | Bin 7188 -> 7652 bytes 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 7d6827a..4a11e62 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,7 @@ dkms.conf *.la *.a *.lib +*.rdi # Executables *.exe diff --git a/build.bat b/build.bat index e23aaad..6c7700c 100644 --- a/build.bat +++ b/build.bat @@ -26,9 +26,13 @@ IF NOT EXIST .\build mkdir .\build pushd .\build rem cl /c %CommonCompilerFlags% %Sources% /I"%mkl_root%\include" rem FOR MSVC /link %mkl_core% %mkl_intel_lp64% %mkl_intel_thread% %libiomp5md% -nvcc -c %CudaSources% -o %CudaObj% -g -G -lcusolver +rem nvcc -c %CudaSources% -o %CudaObj% -g -G -lcusolver rem nvcc -o program.exe -lcusolver -L%mkl_root%/lib/intel64 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -l%MKLCOMPILER%/lib/intel64_win/libiomp5md -cl %CommonCompilerFlags% %Sources% /I"%mkl_root%\include" /link %CudaObj% %cuda_root%/cudart.lib %cuda_root%/cusolver.lib %mkl_core% %mkl_intel_lp64% %mkl_intel_thread% %libiomp5md% +rem cl %CommonCompilerFlags% %Sources% /I"%mkl_root%\include" /link %CudaObj% %cuda_root%/cudart.lib %cuda_root%/cusolver.lib %mkl_core% %mkl_intel_lp64% %mkl_intel_thread% %libiomp5md% + + +cl %CommonCompilerFlags% %Sources% /I"%mkl_root%\include" /link %mkl_core% %mkl_intel_lp64% %mkl_intel_thread% %libiomp5md% + set LastError=%ERRORLEVEL% popd diff --git a/src/main.c b/src/main.c index 0135dfc..ddd7d32 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,12 @@ #include +#define ENABLE_LOGGING 1 +#if ENABLE_LOGGING +#define LOG(msg) { OutputDebugString(msg); } +#else +#define LOG(msg) +#endif + // --- // Header includes #include "base/base_inc.h" @@ -7,7 +14,7 @@ // CUDA headers -#include "kernels.h" +//#include "kernels.h" // --- // .C includes @@ -21,8 +28,6 @@ #define knotpoints_file_path "D:\\dev\\eigsol_gpu\\out\\knotpoints.dat" #define bspline_array_file_path "D:\\dev\\eigsol_gpu\\out\\bsplines.dat" -global U32 enable_logging = 1; - // Complex number with double precision typedef struct Z64 Z64; struct Z64 @@ -57,17 +62,6 @@ struct BSplineCtx global Grid g_grid = {0}; global BSplineCtx g_bspline_ctx = {0}; -//~ Functions - -function inline void -logger_debug(String8 msg) -{ - OutputDebugString(msg.str); -} - -#define LOG(msg) if(enable_logging) { logger_debug(msg) }; - - function void write_array_binary_F64(String8 path_to_file, F64 *values, U32 array_size) { @@ -89,7 +83,7 @@ write_array_binary_F64(String8 path_to_file, F64 *values, U32 array_size) join.sep = str8_lit(" "); join.post = str8_lit("\n"); String8 log_msg = str8_list_join(scratch.arena, log_list, &join); - OutputDebugString(log_msg.str); + LOG(log_msg.str); } OS_file_close(file_handle); } @@ -112,7 +106,7 @@ write_string_list_to_file(Arena *arena, String8 path, String8List *list) join.sep = str8_lit(" "); join.post = str8_lit("\n"); String8 log_msg = str8_list_join(arena, log_list, &join); - OutputDebugString(log_msg.str); + LOG(log_msg.str); } OS_file_close(file_handle); } @@ -336,8 +330,14 @@ void EntryPoint(void) //- Test MKL test_mkl_zgeev(); test_mkl_dsyevd(); - cuda_entry_point(); + LOG("\n\n---- Skipping CUDA part for now ---- \n\n"); + //cuda_entry_point(); + + + + + LOG("\n\n--- End of EntryPoint, exiting program. \n\n"); } diff --git a/src/test_mkl.c b/src/test_mkl.c index 9eedefa..8698c54 100644 --- a/src/test_mkl.c +++ b/src/test_mkl.c @@ -93,7 +93,7 @@ test_mkl_zgeev(void) { {-9.87, 4.82}, {-3.15, 7.36}, {-0.75, 5.23}, { 4.59, 5.41} }; /* Executable statements */ - OutputDebugString( " ZGEEV Example Program Results\n" ); + LOG( " ZGEEV Example Program Results\n" ); /* Query and allocate the optimal workspace */ lwork = -1; zgeev( "Vectors", "Vectors", &n, a, &lda, w, vl, &ldvl, vr, &ldvr, @@ -105,7 +105,7 @@ test_mkl_zgeev(void) { work, &lwork, rwork, &info ); /* Check for convergence */ if( info > 0 ) { - OutputDebugString( "The algorithm failed to compute eigenvalues.\n" ); + LOG( "The algorithm failed to compute eigenvalues.\n" ); exit( 1 ); } /* Print eigenvalues */ @@ -126,15 +126,15 @@ print_matrix_cmplx16( char* desc, int m, int n, MKL_Complex16* a, int lda ) { int i, j; String8 newline = str8_lit("\n"); String8 header = str8_pushf(scratch.arena, "\n %s\n", desc ); - OutputDebugString(header.str); + LOG(header.str); //printf("\n %s \n", desc); for( i = 0; i < m; i++ ) { for( j = 0; j < n; j++ ) { String8 outstr = str8_pushf(scratch.arena, " (%6.2f,%6.2f)", a[i+j*lda].real, a[i+j*lda].imag ); - OutputDebugString(outstr.str); + LOG(outstr.str); //printf(" (%6.2f,%6.2f)", a[i+j*lda].real, a[i+j*lda].imag ); } - OutputDebugString(newline.str); + LOG(newline.str); //printf("\n"); } } @@ -224,7 +224,7 @@ test_mkl_dsyevd(void) { -3.18, 7.21, -7.42, 8.54, 2.51 }; /* Executable statements */ - OutputDebugString( " DSYEVD Example Program Results\n" ); + LOG( " DSYEVD Example Program Results\n" ); /* Query and allocate the optimal workspace */ lwork = -1; liwork = -1; @@ -239,7 +239,7 @@ test_mkl_dsyevd(void) { &liwork, &info ); /* Check for convergence */ if( info > 0 ) { - OutputDebugString( "The algorithm failed to compute eigenvalues.\n" ); + LOG( "The algorithm failed to compute eigenvalues.\n" ); exit( 1 ); } /* Print eigenvalues */ @@ -257,15 +257,15 @@ void print_matrix( char* desc, int m, int n, double* a, int lda ) { int i, j; //printf( "\n %s\n", desc ); String8 header = str8_pushf(scratch.arena, "\n %s\n", desc); - OutputDebugString(header.str); + LOG(header.str); for( i = 0; i < m; i++ ) { for( j = 0; j < n; j++ ) { String8 out = str8_pushf(scratch.arena, " %6.2f", a[i+j*lda] ); - OutputDebugString(out.str); + LOG(out.str); //printf( " %6.2f", a[i+j*lda] ); } - OutputDebugString(str8_lit("\n").str); + LOG(str8_lit("\n").str); } } diff --git a/timeBuild.ctm b/timeBuild.ctm index 90e9a3418d2cc358d269eba25bbc3aa1c2490ae1..93129fc0ee140a1ee730196e6566f65034b8b053 100644 GIT binary patch delta 475 zcmbPY@x*$Ah)n(Yw!H`TD%@sdW?*3G6JlVPu!i{#h|dV*D>E@L98k@F3X^vN^5@F9 zKZEf#fQk-;?1A$wfqX$u=I1bZO(6eFc>tVm0p$PUn*rwohkpvpB>sDYZj9(7qXRSNA7^WWNW5?*~EigXF z!dV!hztM?y#mYt