<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Forum: C++ Source Codes - Recent Posts</title>
		<link>https://www.k-wave.org/forum/forum/c-source-codes</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 13 Oct 2026 07:10:44 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="https://www.k-wave.org/forum/rss/forum/c-source-codes" rel="self" type="application/rss+xml" />

		<item>
			<title>mhopeng on "Compiled OMP code does not give correct results"</title>
			<link>https://www.k-wave.org/forum/topic/compiled-omp-code-does-not-give-correct-results#post-9175</link>
			<pubDate>Mon, 20 Jan 2025 02:20:53 +0000</pubDate>
			<dc:creator>mhopeng</dc:creator>
			<guid isPermaLink="false">9175@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62; I compiled kspaceFirstOrder-OMP for macOS following the instructions by @wsimson (thank you for those!):&#60;br /&#62;
&#60;a href=&#34;https://github.com/waltsims/k-wave-omp-darwin&#34; rel=&#34;nofollow&#34;&#62;https://github.com/waltsims/k-wave-omp-darwin&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Compilation seems to work fine. To test it, I modified the k-wave example &#34;example_us_beam_patterns.m&#34; to use the compiled binary by changing &#60;code&#62;kspaceFirstOrder3D&#60;/code&#62; to &#60;code&#62;kspaceFirstOrder3DC&#60;/code&#62;. The binary code is run, but the resulting plots are not right: the RMS pressure plot is all zero and the plot of maximum pressure is all -3.402 MPa. Is there some other step I need to use the compiled OMP code? &#60;/p&#62;
&#60;p&#62;Thank you! -Matt H.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jiri Jaros on "Comprehensive guide to run k-Wave on the latest hardware (GPU)"</title>
			<link>https://www.k-wave.org/forum/topic/comprehensive-guide-to-run-k-wave-on-the-latest-hardware-gpu#post-9172</link>
			<pubDate>Wed, 15 Jan 2025 13:03:45 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">9172@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you very much! I’ll review it and consider incorporating it into the official version. I also plan to update the manual to include a time comparison with newer GPUs. :)&#60;/p&#62;
&#60;p&#62;Additionally, I noticed that GCC 13+ compilers have changed how infinity is handled. The following lines now cause the simulation to end with NaNs.&#60;/p&#62;
&#60;p&#62;if (absorbNabla1[i] ==  std::numeric_limits&#38;lt;float&#38;gt;::infinity()) absorbNabla1[i] = 0.0f;&#60;br /&#62;
if (absorbNabla2[i] ==  std::numeric_limits&#38;lt;float&#38;gt;::infinity()) absorbNabla2[i] = 0.0f;&#60;/p&#62;
&#60;p&#62;a simple, however, not the best fix is:&#60;/p&#62;
&#60;p&#62;   // Comparison with infinity is not supported with --ffast-math enabled&#60;br /&#62;
if (absorbNabla1[i] &#38;gt;= std::numeric_limits&#38;lt;float&#38;gt;::max()) absorbNabla1[i] = 0.0f;&#60;br /&#62;
if (absorbNabla2[i] &#38;gt;= std::numeric_limits&#38;lt;float&#38;gt;::max()) absorbNabla2[i] = 0.0f;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ArteryLee on "Comprehensive guide to run k-Wave on the latest hardware (GPU)"</title>
			<link>https://www.k-wave.org/forum/topic/comprehensive-guide-to-run-k-wave-on-the-latest-hardware-gpu#post-9161</link>
			<pubDate>Fri, 06 Dec 2024 00:41:46 +0000</pubDate>
			<dc:creator>ArteryLee</dc:creator>
			<guid isPermaLink="false">9161@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;@bob2024 Thanks very much for this helpful tutorial!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bob2024 on "Comprehensive guide to run k-Wave on the latest hardware (GPU)"</title>
			<link>https://www.k-wave.org/forum/topic/comprehensive-guide-to-run-k-wave-on-the-latest-hardware-gpu#post-9130</link>
			<pubDate>Tue, 27 Aug 2024 01:11:26 +0000</pubDate>
			<dc:creator>bob2024</dc:creator>
			<guid isPermaLink="false">9130@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;A week ago, I struggled to run the C++ version of k-Wave on the latest hardware. After spending some time and using existing resources from the forum, I was able to overcome the issue. So, I created this repository with a comprehensive guide for both Windows and Linux. I hope it helps others.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/bobqianic/k-Wave/tree/main&#34; rel=&#34;nofollow&#34;&#62;https://github.com/bobqianic/k-Wave/tree/main&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wsimson on "C++ source compilation on Apple M1 Pro"</title>
			<link>https://www.k-wave.org/forum/topic/c-source-compilation-on-apple-m1-pro#post-9110</link>
			<pubDate>Thu, 11 Jul 2024 17:38:34 +0000</pubDate>
			<dc:creator>wsimson</dc:creator>
			<guid isPermaLink="false">9110@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hey mmj,&#60;/p&#62;
&#60;p&#62;I have compiled OMP for MacOS here: &#60;a href=&#34;https://github.com/waltsims/k-wave-omp-darwin&#34; rel=&#34;nofollow&#34;&#62;https://github.com/waltsims/k-wave-omp-darwin&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Let me know if this works for you. This is the version of the binaries we use for k-wave-python.&#60;/p&#62;
&#60;p&#62;Hope this helps!&#60;br /&#62;
Walter
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mmj on "C++ source compilation on Apple M1 Pro"</title>
			<link>https://www.k-wave.org/forum/topic/c-source-compilation-on-apple-m1-pro#post-9107</link>
			<pubDate>Wed, 03 Jul 2024 18:19:54 +0000</pubDate>
			<dc:creator>mmj</dc:creator>
			<guid isPermaLink="false">9107@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;I am new to this, so I already apologize for my naivety here.  &#60;/p&#62;
&#60;p&#62;I am trying to compile C++ source codes for kspaceFirstOrder-OMP binaries on my MacOS, Sonoma 14.5. I downloaded the source code &#34;k-wave-toolbox-version-1.3-cpp-linux-source&#34; from &#60;a href=&#34;http://www.k-wave.org/download.php&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/download.php&#60;/a&#62;. &#60;/p&#62;
&#60;p&#62;I am getting the following error after attempting to make:&#60;/p&#62;
&#60;p&#62;g++ -m64 -march=native -mtune=native -O3 -ffast-math -fassociative-math  -Wall  -Xpreprocessor -fopenmp -lomp -std=c++11 -D__KWAVE_GIT_HASH__=\&#34;0ba023063e3f29685e1e346f56883378d961f9f1\&#34; -I/opt/homebrew/opt/hdf5/include -I/opt/homebrew/opt/fftw/include -I. -o main.o -c main.cpp&#60;br /&#62;
clang: warning: -lomp: 'linker' input unused [-Wunused-command-line-argument]&#60;br /&#62;
main.cpp:798:12: fatal error: 'omp.h' file not found&#60;br /&#62;
  #include &#38;lt;omp.h&#38;gt;&#60;br /&#62;
           ^~~~~~~&#60;br /&#62;
1 error generated.&#60;br /&#62;
make: *** [Makefile:313: main.o] Error 1.&#60;/p&#62;
&#60;p&#62;--------------------------------------------&#60;/p&#62;
&#60;p&#62;If use &#34;make -j&#34; to run multiple tasks concurrently, I am getting like 20 errors including:&#60;/p&#62;
&#60;p&#62;In file included from MatrixClasses/RealMatrix.cpp:34:&#60;br /&#62;
In file included from ./Logger/Logger.h:39:&#60;br /&#62;
./Logger/OutputMessages.h:47:1: error: unknown type name 'OutputMessage'&#60;br /&#62;
OutputMessage kOutFmtDone&#60;br /&#62;
^&#60;br /&#62;
./Logger/OutputMessages.h:48:18: error: use of undeclared identifier 'kOutFmtEol'&#60;br /&#62;
  = &#34;  Done &#34; +  kOutFmtEol;&#60;/p&#62;
&#60;p&#62;.&#60;br /&#62;
.&#60;br /&#62;
.&#60;br /&#62;
-------------------------------------------&#60;/p&#62;
&#60;p&#62;I used &#34;homebrew&#34; to install required packages and libraries. The &#34;Makefile&#34; that I am using is copied below. &#60;/p&#62;
&#60;p&#62;Has anyone tried compiling OMP source codes on M1 processor facing the same issue? I was just wondering if this is relevant to OpenMP parallelization on M1 Pro or whether the error is related to my libraries/packages. &#60;/p&#62;
&#60;p&#62;Thank you in advance for your help. &#60;/p&#62;
&#60;p&#62;-Morteza &#60;/p&#62;
&#60;p&#62;# /**&#60;br /&#62;
# * @file      Makefile&#60;br /&#62;
# * @author    Jiri Jaros&#60;br /&#62;
# *            Faculty of Information Technology&#60;br /&#62;
# *            Brno University of Technology&#60;br /&#62;
# * @email     &#60;a href=&#34;mailto:jarosjir@fit.vutbr.cz&#34;&#62;jarosjir@fit.vutbr.cz&#60;/a&#62;&#60;br /&#62;
# * @comments  Linux makefile for Release version on Ubuntu 18.04&#60;br /&#62;
# *&#60;br /&#62;
# * @tool      kspaceFirstOrder 2.17&#60;br /&#62;
# * @created   04 September 2017, 12:50&#60;br /&#62;
# * @lastModif 26 February  2020, 16:20&#60;br /&#62;
# *&#60;br /&#62;
# * @copyright Copyright (C) 2017 - 2020 SC\@FIT Research Group,&#60;br /&#62;
# *            Brno University of Technology, Brno, CZ.&#60;br /&#62;
# *&#60;br /&#62;
# * This file is part of the C++ extension of the k-Wave Toolbox&#60;br /&#62;
# * (&#60;a href=&#34;http://www.k-wave.org)&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org)&#60;/a&#62;.&#60;br /&#62;
# *&#60;br /&#62;
# * This file is part of the k-Wave. k-Wave is free software: you can&#60;br /&#62;
# * redistribute it and/or modify it under the terms of the GNU Lesser General&#60;br /&#62;
# * Public License as published by the Free Software Foundation, either version&#60;br /&#62;
# * 3 of the License, or (at your option) any later version.&#60;br /&#62;
# *&#60;br /&#62;
# * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY&#60;br /&#62;
# * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&#60;br /&#62;
# * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for&#60;br /&#62;
# * more details.&#60;br /&#62;
# *&#60;br /&#62;
# * You should have received a copy of the GNU Lesser General Public License&#60;br /&#62;
# * along with k-Wave.&#60;br /&#62;
# * If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).&#60;br /&#62;
# */&#60;/p&#62;
&#60;p&#62;################################################################################&#60;br /&#62;
#                                                                              #&#60;br /&#62;
# The source codes can be compiled ONLY under Linux x64 by GNU g++ 6.0 and     #&#60;br /&#62;
# newer, or Intel Compiler icpc 2018 and newer. The newer the compiler, the    #&#60;br /&#62;
# more advanced instruction set can be used.                                   #&#60;br /&#62;
# We recommend compilation with g++ 8.3 or icpc 2019.                          #&#60;br /&#62;
#                                                                              #&#60;br /&#62;
# This makefile uses the GNU compiler and static linking by default.           #&#60;br /&#62;
#                                                                              #&#60;br /&#62;
# Necessary libraries:                                                         #&#60;br /&#62;
#  - FFTW 3.3.x and newer, or Intel MKL 2018 and newer                         #&#60;br /&#62;
#  - HDF5 version 1.8.x and newer                                              #&#60;br /&#62;
#                                                                              #&#60;br /&#62;
# How to compile libraries                                                     #&#60;br /&#62;
#  - FFTW : download from &#34;http://www.fftw.org/&#34;                               #&#60;br /&#62;
#           run configure script with following parameters:                    #&#60;br /&#62;
#             --enable-float --enable-avx --enable-openmp                      #&#60;br /&#62;
#               or                                                             #&#60;br /&#62;
#             --enable-float --enable-avx2 --enable-openmp                     #&#60;br /&#62;
#  - MKL  : Only if not using FFTW. Dowload from                               #&#60;br /&#62;
#           &#34;http://software.intel.com/en-us/intel-mkl&#34;                        #&#60;br /&#62;
#  - HDF5 : download from                                                      #&#60;br /&#62;
#           &#34;https://www.hdfgroup.org/downloads/hdf5/source-code/&#34;             #&#60;br /&#62;
#           run configure script with these parameters:                        #&#60;br /&#62;
#             --enable-hl --enable-static --enable-shared                      #&#60;br /&#62;
#                                                                              #&#60;br /&#62;
# How to compile the code                                                      #&#60;br /&#62;
#  1. Select the compiler (GNU + FFTW or Intel + MKL).                         #&#60;br /&#62;
#  2. Select one of the linking possibilities.                                 #&#60;br /&#62;
#  3. Select CPU architecture (native binary is default).                      #&#60;br /&#62;
#  4. Load necessary software modules, or set the library paths manually.      #&#60;br /&#62;
#  5. make -j                                                                  #&#60;br /&#62;
#                                                                              #&#60;br /&#62;
################################################################################&#60;/p&#62;
&#60;p&#62;################################################################################&#60;br /&#62;
#         Set following flags based on your compiler and library paths         #&#60;br /&#62;
################################################################################&#60;/p&#62;
&#60;p&#62;# Select compiler. GNU is default but Intel may be faster.&#60;br /&#62;
COMPILER = GNU&#60;br /&#62;
#COMPILER = Intel&#60;/p&#62;
&#60;p&#62;# Static lining is default&#60;br /&#62;
 LINKING = STATIC&#60;br /&#62;
#LINKING = DYNAMIC&#60;/p&#62;
&#60;p&#62;# Set up paths: If using modules, the paths are set up automatically,&#60;br /&#62;
##               otherwise, set paths manually&#60;br /&#62;
#MKL_DIR  = $(EBROOTMKL)&#60;br /&#62;
#FFT_DIR  = $(EBROOTFFTW)&#60;br /&#62;
#HDF5_DIR = $(EBROOTHDF5)&#60;br /&#62;
#ZLIB_DIR = $(EBROOTZLIB)&#60;br /&#62;
#SZIP_DIR = $(EBROOTSZIP)&#60;/p&#62;
&#60;p&#62;## homebrew installations, set paths manually&#60;br /&#62;
FFT_DIR  = /opt/homebrew/opt/fftw&#60;br /&#62;
HDF5_DIR = /opt/homebrew/opt/hdf5&#60;br /&#62;
ZLIB_DIR = /opt/homebrew/opt/zlib&#60;br /&#62;
SZIP_DIR = /opt/homebrew/opt/szip&#60;/p&#62;
&#60;p&#62;# Select CPU architecture (what instruction set to be used).&#60;br /&#62;
# The libraries such as FFTW, HDF5 and MKL are to be compiled under the same&#60;br /&#62;
# architecture, e.g., if you want to use AVX in k-Wave, compile FFTW with&#60;br /&#62;
# --enable-avx&#60;br /&#62;
# The native architecture will compile and optimize the code for the underlying&#60;br /&#62;
# processor.&#60;br /&#62;
# Fat binary, available only for Intel, includes all AVX, AVX2 and AVX512 sets.&#60;/p&#62;
&#60;p&#62;CPU_ARCH = native&#60;br /&#62;
#CPU_ARCH = AVX&#60;br /&#62;
#CPU_ARCH = AVX2&#60;br /&#62;
#CPU_ARCH = AVX512&#60;br /&#62;
#CPU_ARCH = FAT_BIN&#60;/p&#62;
&#60;p&#62;############################### Common flags ###################################&#60;br /&#62;
# Git hash of release 1.3&#60;br /&#62;
GIT_HASH       = -D__KWAVE_GIT_HASH__=\&#34;0ba023063e3f29685e1e346f56883378d961f9f1\&#34;&#60;/p&#62;
&#60;p&#62;# Replace tabs by spaces&#60;br /&#62;
.RECIPEPREFIX += &#60;/p&#62;
&#60;p&#62;################################ GNU g++ + FFTW ################################&#60;br /&#62;
ifeq ($(COMPILER), GNU)&#60;br /&#62;
  # Compiler name&#60;br /&#62;
  CXX       = g++&#60;/p&#62;
&#60;p&#62;  # C++ standard&#60;br /&#62;
  CPP_STD   = -std=c++11&#60;/p&#62;
&#60;p&#62;  # Enable OpenMP&#60;br /&#62;
#  OPENMP    = -fopenmp&#60;br /&#62;
  OPENMP 	 = -Xpreprocessor -fopenmp -lomp&#60;/p&#62;
&#60;p&#62;  # Set CPU architecture&#60;br /&#62;
  # Sandy Bridge, Ivy Bridge&#60;br /&#62;
  ifeq ($(CPU_ARCH), AVX)&#60;br /&#62;
    CPU_FLAGS = -m64 -mavx&#60;/p&#62;
&#60;p&#62;   # Haswell, Broadwell&#60;br /&#62;
  else ifeq ($(CPU_ARCH), AVX2)&#60;br /&#62;
    CPU_FLAGS = -m64 -mavx2&#60;/p&#62;
&#60;p&#62;  # Skylake-X, Ice Lake, Cannon Lake&#60;br /&#62;
  else ifeq ($(CPU_ARCH), AVX512)&#60;br /&#62;
    CPU_FLAGS = -m64 -mavx512f&#60;/p&#62;
&#60;p&#62;  # Defautl is native - the max performance for this CPU&#60;br /&#62;
  else&#60;br /&#62;
    CPU_FLAGS = -m64 -march=native -mtune=native&#60;br /&#62;
  endif&#60;/p&#62;
&#60;p&#62;  # Use maximum optimization&#60;br /&#62;
  OPT       = -O3 -ffast-math -fassociative-math&#60;/p&#62;
&#60;p&#62;  # Debug flags&#60;br /&#62;
  DEBUG     =&#60;br /&#62;
  # Profile flags&#60;br /&#62;
  PROFILE   =&#60;br /&#62;
  # C++ warning flags&#60;br /&#62;
  WARNING   = -Wall&#60;/p&#62;
&#60;p&#62;  # Add include directories&#60;br /&#62;
  INCLUDES  = -I$(HDF5_DIR)/include -I$(FFT_DIR)/include -I.&#60;br /&#62;
  # Add library directories&#60;br /&#62;
  LIB_PATHS = -L$(HDF5_DIR)/lib -L$(FFT_DIR)/lib&#60;/p&#62;
&#60;p&#62;  # Set compiler flags and header files directories&#60;br /&#62;
  CXXFLAGS  = $(CPU_FLAGS) $(OPT) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
              $(OPENMP) $(CPP_STD)                               \&#60;br /&#62;
              $(GIT_HASH)                                        \&#60;br /&#62;
              $(INCLUDES)&#60;/p&#62;
&#60;p&#62;  # Set linker flags and library files directories&#60;br /&#62;
  ifeq ($(LINKING), STATIC)&#60;br /&#62;
        # Static link&#60;br /&#62;
        LDFLAGS = $(CPU_FLAGS) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
                  $(OPENMP) $(CPP_STD)                        \&#60;br /&#62;
                  $(LIB_PATHS)                                \&#60;br /&#62;
                  -static&#60;/p&#62;
&#60;p&#62;        LDLIBS  = $(FFT_DIR)/lib/libfftw3f.a     \&#60;br /&#62;
                  $(FFT_DIR)/lib/libfftw3f_omp.a \&#60;br /&#62;
                  $(HDF5_DIR)/lib/libhdf5_hl.a   \&#60;br /&#62;
                  $(HDF5_DIR)/lib/libhdf5.a      \&#60;br /&#62;
                  $(ZLIB_DIR)/lib/libz.a         \&#60;br /&#62;
                  $(SZIP_DIR)/lib/libsz.a        \&#60;br /&#62;
                  -lm -lmvec                     \&#60;br /&#62;
                  -ldl  # We need this for HDF5-1.8.11 and newer&#60;/p&#62;
&#60;p&#62;    else&#60;br /&#62;
        # Dynamic link with runtime paths&#60;br /&#62;
        LDFLAGS = $(CPU_FLAGS) $(OPT) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
                   $(OPENMP) $(CPP_STD)                              \&#60;br /&#62;
                   $(LIB_PATHS)                                      \&#60;br /&#62;
                   -Wl,-rpath,$(HDF5_DIR)/lib:$(FFT_DIR)/lib&#60;/p&#62;
&#60;p&#62;        LDLIBS  = -lfftw3f -lfftw3f_omp -lhdf5 -lhdf5_hl -lm -lz&#60;br /&#62;
  endif&#60;br /&#62;
endif&#60;/p&#62;
&#60;p&#62;########################### Intel Compiler + MKL ###############################&#60;br /&#62;
ifeq ($(COMPILER), Intel)&#60;br /&#62;
  # Compiler name&#60;br /&#62;
  CXX       = icpc&#60;/p&#62;
&#60;p&#62;  # C++ standard&#60;br /&#62;
  CPP_STD   = -std=c++11&#60;/p&#62;
&#60;p&#62;  # Enable OpenMP&#60;br /&#62;
  OPENMP    = -qopenmp&#60;/p&#62;
&#60;p&#62;  # Set CPU architecture&#60;br /&#62;
  # Sandy Bridge, Ivy Bridge&#60;br /&#62;
  ifeq ($(CPU_ARCH), AVX)&#60;br /&#62;
    CPU_FLAGS = -m64 -xAVX&#60;/p&#62;
&#60;p&#62;  # Haswell, Broadwell&#60;br /&#62;
  else ifeq ($(CPU_ARCH), AVX2)&#60;br /&#62;
    CPU_FLAGS = -m64 -xCORE-AVX2&#60;/p&#62;
&#60;p&#62;  # Skylake-X, Ice Lake, Cannon Lake&#60;br /&#62;
  else ifeq ($(CPU_ARCH), AVX512)&#60;br /&#62;
    CPU_FLAGS = -m64 -xCORE-AVX512&#60;/p&#62;
&#60;p&#62;  # AMD-AVX, Intel's AVX, AVX2 and AVX-512&#60;br /&#62;
  else ifeq ($(CPU_ARCH), FAT_BIN)&#60;br /&#62;
    CPU_FLAGS = -m64 -mavx -axCORE-AVX2,CORE-AVX512&#60;/p&#62;
&#60;p&#62;  # Defautl is native - the max performance for this CPU&#60;br /&#62;
  else&#60;br /&#62;
    CPU_FLAGS = -m64 -xhost&#60;br /&#62;
  endif&#60;/p&#62;
&#60;p&#62;  # Use maximum optimization&#60;br /&#62;
  OPT       = -Ofast -ipo&#60;/p&#62;
&#60;p&#62;  # Debug flags&#60;br /&#62;
  DEBUG     =&#60;br /&#62;
  # Profile flags&#60;br /&#62;
  PROFILE   =&#60;br /&#62;
  # C++ warning flags&#60;br /&#62;
  WARNING   = -Wall&#60;/p&#62;
&#60;p&#62;  # Add include directories&#60;br /&#62;
  INCLUDES  = -I$(HDF5_DIR)/include -I.&#60;br /&#62;
  # Add library directories&#60;br /&#62;
  LIB_PATHS = -L$(HDF5_DIR)/lib&#60;/p&#62;
&#60;p&#62;  # Set compiler flags and header files directories&#60;br /&#62;
  CXXFLAGS  = $(CPU_FLAGS) $(OPT) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
              $(OPENMP) $(CPP_STD)                               \&#60;br /&#62;
              $(GIT_HASH)                                        \&#60;br /&#62;
              $(INCLUDES)&#60;/p&#62;
&#60;p&#62;  # Set linker flags&#60;br /&#62;
  ifeq ($(LINKING), STATIC)&#60;br /&#62;
        LDFLAGS = $(CPU_FLAGS) $(OPT) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
                  $(OPENMP) $(CPP_STD)                               \&#60;br /&#62;
                  $(LIB_PATHS)                                       \&#60;br /&#62;
                  -mkl=parallel -static-intel -qopenmp-link=static&#60;/p&#62;
&#60;p&#62;        LDLIBS  = $(HDF5_DIR)/lib/libhdf5_hl.a  \&#60;br /&#62;
                  $(HDF5_DIR)/lib/libhdf5.a     \&#60;br /&#62;
                  $(ZLIB_DIR)/lib/libz.a        \&#60;br /&#62;
                  $(SZIP_DIR)/lib/libsz.a       \&#60;br /&#62;
                  -lm -ldl&#60;/p&#62;
&#60;p&#62;  else&#60;br /&#62;
        # Dynamic link with runtime paths&#60;br /&#62;
        LDFLAGS = $(CPU_FLAGS) $(OPT) $(DEBUG) $(WARNING) $(PROFILE) \&#60;br /&#62;
                  $(OPENMP) $(CPP_STD)                               \&#60;br /&#62;
                  $(LIB_PATHS)                                       \&#60;br /&#62;
                  -Wl,-rpath,$(HDF5_DIR)/lib                         \&#60;br /&#62;
                  -mkl=parallel&#60;/p&#62;
&#60;p&#62;        LDLIBS  = -lhdf5 -lhdf5_hl -lz -lsz&#60;/p&#62;
&#60;p&#62;  endif&#60;br /&#62;
endif&#60;/p&#62;
&#60;p&#62;################################### Build ######################################&#60;br /&#62;
# Target binary name&#60;br /&#62;
TARGET       = kspaceFirstOrder-OMP&#60;/p&#62;
&#60;p&#62;# Units to be compiled&#60;br /&#62;
DEPENDENCIES = main.o                                  \&#60;br /&#62;
               Containers/MatrixContainer.o            \&#60;br /&#62;
               Containers/OutputStreamContainer.o      \&#60;br /&#62;
               Hdf5/Hdf5File.o                         \&#60;br /&#62;
               Hdf5/Hdf5FileHeader.o                   \&#60;br /&#62;
               KSpaceSolver/KSpaceFirstOrderSolver.o   \&#60;br /&#62;
               Logger/Logger.o                         \&#60;br /&#62;
               MatrixClasses/BaseFloatMatrix.o         \&#60;br /&#62;
               MatrixClasses/BaseIndexMatrix.o         \&#60;br /&#62;
               MatrixClasses/ComplexMatrix.o           \&#60;br /&#62;
               MatrixClasses/FftwComplexMatrix.o       \&#60;br /&#62;
               MatrixClasses/FftwRealMatrix.o          \&#60;br /&#62;
               MatrixClasses/IndexMatrix.o             \&#60;br /&#62;
               MatrixClasses/RealMatrix.o              \&#60;br /&#62;
               OutputStreams/BaseOutputStream.o        \&#60;br /&#62;
               OutputStreams/IndexOutputStream.o       \&#60;br /&#62;
               OutputStreams/CuboidOutputStream.o      \&#60;br /&#62;
               OutputStreams/WholeDomainOutputStream.o \&#60;br /&#62;
               Parameters/CommandLineParameters.o      \&#60;br /&#62;
               Parameters/Parameters.o&#60;/p&#62;
&#60;p&#62;# Build target&#60;br /&#62;
all: $(TARGET)&#60;/p&#62;
&#60;p&#62;# Link target&#60;br /&#62;
$(TARGET): $(DEPENDENCIES)&#60;br /&#62;
	$(CXX) $(LDFLAGS) $(DEPENDENCIES) $(LDLIBS) -o $@&#60;/p&#62;
&#60;p&#62;# Compile units&#60;br /&#62;
%.o: %.cpp&#60;br /&#62;
	$(CXX) $(CXXFLAGS) -o $@ -c $&#38;lt;&#60;/p&#62;
&#60;p&#62;# Clean repository&#60;br /&#62;
.PHONY: clean&#60;br /&#62;
clean:&#60;br /&#62;
	rm -f $(DEPENDENCIES) $(TARGET)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pamparana on "How to run the C++ version for this loop"</title>
			<link>https://www.k-wave.org/forum/topic/how-to-run-the-c-version-for-this-loop#post-9033</link>
			<pubDate>Tue, 06 Feb 2024 21:56:50 +0000</pubDate>
			<dc:creator>pamparana</dc:creator>
			<guid isPermaLink="false">9033@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am trying to port the diagnostic US example and trying to run this using the C++ code. Considering following matlab loop:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% loop through the scan lines
for scan_line_index = 1:number_scan_lines

    % load the current section of the medium
    medium.sound_speed = sound_speed_map(:, medium_position:medium_position + Ny - 1, :);
    medium.density = density_map(:, medium_position:medium_position + Ny - 1, :);

    % run the simulation
    sensor_data = kspaceFirstOrder3D(kgrid, medium, transducer, transducer, input_args{:});

    % extract the scan line from the sensor data
    scan_lines(scan_line_index, :) = transducer.scan_line(sensor_data);

    % update medium position
    medium_position = medium_position + transducer.element_width;

end&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;If I understand correctly, if I need to move this to C++, I should basically create HD5 input file for every call to &#60;code&#62;kspaceFirstOrder3D&#60;/code&#62; and them call the C++ application with that input file. So, is it correct that if I want to reproduce this example, I need to create &#60;code&#62;number_scan_lines&#60;/code&#62; HD5 input files and then call the C++ program on each of them?&#60;/p&#62;
&#60;p&#62;Assuming this is correct, the next matlab line in the example is:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;scan_lines(scan_line_index, :) = transducer.scan_line(sensor_data);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;How do I then create the scan lines array from the C++ outputs?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>daga_pankaj on "using newer versions of CUDA"</title>
			<link>https://www.k-wave.org/forum/topic/using-newer-versions-of-cuda#post-9025</link>
			<pubDate>Tue, 30 Jan 2024 13:13:53 +0000</pubDate>
			<dc:creator>daga_pankaj</dc:creator>
			<guid isPermaLink="false">9025@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;@wsimson&#60;/p&#62;
&#60;p&#62;I am planning to use this on the T4 architecture with something similar like the diagnostics US B-mode image. How much speedup do you hink I can expect with T4 with 16 GM of RAM?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>daga_pankaj on "using newer versions of CUDA"</title>
			<link>https://www.k-wave.org/forum/topic/using-newer-versions-of-cuda#post-9023</link>
			<pubDate>Mon, 29 Jan 2024 19:15:35 +0000</pubDate>
			<dc:creator>daga_pankaj</dc:creator>
			<guid isPermaLink="false">9023@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thanks! I will give it a shot!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wsimson on "using newer versions of CUDA"</title>
			<link>https://www.k-wave.org/forum/topic/using-newer-versions-of-cuda#post-9010</link>
			<pubDate>Sat, 20 Jan 2024 00:56:32 +0000</pubDate>
			<dc:creator>wsimson</dc:creator>
			<guid isPermaLink="false">9010@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hey Daga,&#60;/p&#62;
&#60;p&#62;If you don't want to compile them from source, I've re-compiled the CUDA binaries here for linux use in k-wave-python:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/waltsims/kspaceFirstOrder-CUDA-linux/releases/tag/v1.3.1&#34; rel=&#34;nofollow&#34;&#62;https://github.com/waltsims/kspaceFirstOrder-CUDA-linux/releases/tag/v1.3.1&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>daga_pankaj on "using newer versions of CUDA"</title>
			<link>https://www.k-wave.org/forum/topic/using-newer-versions-of-cuda#post-9002</link>
			<pubDate>Fri, 05 Jan 2024 23:28:34 +0000</pubDate>
			<dc:creator>daga_pankaj</dc:creator>
			<guid isPermaLink="false">9002@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Will the code work with newer versions of CUDA? The documentation says CUDA 7.5 which is quite old and wondering if anyone has tried it with cuda &#38;gt;=11+
&#60;/p&#62;</description>
		</item>
		<item>
			<title>BIlly on "GPU error: an illegal memory access was encountered routine"</title>
			<link>https://www.k-wave.org/forum/topic/gpu-error-an-illegal-memory-access-was-encountered-routine#post-8915</link>
			<pubDate>Thu, 21 Sep 2023 14:58:24 +0000</pubDate>
			<dc:creator>BIlly</dc:creator>
			<guid isPermaLink="false">8915@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;After 3 straight days trying to debug this the error seems to have gone away on its own, that's computers for you :) Hopefully I don't encounter it again...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>BIlly on "GPU error: an illegal memory access was encountered routine"</title>
			<link>https://www.k-wave.org/forum/topic/gpu-error-an-illegal-memory-access-was-encountered-routine#post-8912</link>
			<pubDate>Fri, 15 Sep 2023 17:27:01 +0000</pubDate>
			<dc:creator>BIlly</dc:creator>
			<guid isPermaLink="false">8912@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I'm very suspicious the error is caused by the GPU not releasing enough resources after the first process is complete, which would explain why the 2D reconstructions (which barely use any resources) are running fine. My forward simulations are on a 1024*128*1024 grid at 32 bit floating point precision, the A100s have 80GB of GPU RAM which should be more than enough.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Billy.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>BIlly on "GPU error: an illegal memory access was encountered routine"</title>
			<link>https://www.k-wave.org/forum/topic/gpu-error-an-illegal-memory-access-was-encountered-routine#post-8911</link>
			<pubDate>Fri, 15 Sep 2023 15:31:41 +0000</pubDate>
			<dc:creator>BIlly</dc:creator>
			<guid isPermaLink="false">8911@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Greetings all, &#60;/p&#62;
&#60;p&#62;First off let me say K-Wave has been an invaluable tool for me and it's been running brilliantly on my workstation for months. Since I intend to run bigger simulations (and lots of them) I'm now trying to run kspaceFirstOrder-CUDA on my department's HPC using A100s. Unfortunately it doesn't seem to get very far and I receive the following:&#60;br /&#62;
'&#60;br /&#62;
INFO:root:k-wave forward, cycle: 1, wavelength_index: 1, pulse: 1&#60;br /&#62;
INFO:root:p0 loaded in 0.09530607238411903 seconds&#60;br /&#62;
INFO:root:kwave forward run in 229.18575995601714 seconds&#60;br /&#62;
INFO:root:sensor data saved in 0.010119317099452019 seconds&#60;br /&#62;
INFO:root:k-wave forward, cycle: 1, wavelength_index: 2, pulse: 1&#60;br /&#62;
INFO:root:p0 loaded in 0.021063480526208878 seconds&#60;br /&#62;
┌───────────────────────────────────────────────────────────────┐&#60;br /&#62;
│            !!! K-Wave experienced a fatal error !!!           │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ GPU error: an illegal memory access was encountered routine   │&#60;br /&#62;
│        name: cudaGetLastError() in file OutputStreams/        │&#60;br /&#62;
│        OutputStreamsCudaKernels.cu, line 130.                 │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                      Execution terminated                     │&#60;br /&#62;
└───────────────────────────────────────────────────────────────┘&#60;br /&#62;
'&#60;br /&#62;
Now my script is simulating time-series images, so it runs k-wave multiple times. For the first run (&#34;cycle: 1, wavelength_index: 1, pulse: 1&#34;), it works fine! The output also seems completely sensible. But as soon as it reaches pulse number two it encounters the error. It's most probably related to the HPC since I haven't encountered this on my workstation, just wondering if anybody has seen anything similar or might have any idea as to what's causing this? The time reversal reconstructions are also set to run after the forward simulations and these are completely fine - although they are 2D and thus only require a fraction of the resources.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>chengoway on "Windows build instructions"</title>
			<link>https://www.k-wave.org/forum/topic/windows-build-instructions#post-8891</link>
			<pubDate>Mon, 07 Aug 2023 15:45:07 +0000</pubDate>
			<dc:creator>chengoway</dc:creator>
			<guid isPermaLink="false">8891@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Really thank you for your effort.it helps me in solving a lot of problems
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tnie on "Windows build instructions"</title>
			<link>https://www.k-wave.org/forum/topic/windows-build-instructions#post-8890</link>
			<pubDate>Thu, 03 Aug 2023 00:33:05 +0000</pubDate>
			<dc:creator>tnie</dc:creator>
			<guid isPermaLink="false">8890@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi all, I patched the Windows C++ CUDA source code for it to build easily with Visual Studio 2022 and VCPKG. The advantage of using VCPKG is that it automates building dependencies (HDF5, zlib, szip) from source. Hope the community will find it useful. I needed to build from source to support a newer GPU.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/kwsp/k-wave-toolbox-version-1.3-cpp-windows-source/tree/main/kspaceFirstOrder-CUDA&#34; rel=&#34;nofollow&#34;&#62;https://github.com/kwsp/k-wave-toolbox-version-1.3-cpp-windows-source/tree/main/kspaceFirstOrder-CUDA&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tnie on "Github Repo for source"</title>
			<link>https://www.k-wave.org/forum/topic/github-repo-for-source#post-8889</link>
			<pubDate>Wed, 02 Aug 2023 22:54:21 +0000</pubDate>
			<dc:creator>tnie</dc:creator>
			<guid isPermaLink="false">8889@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I second this! It would be easier for the community to contribute.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>f841r on "Github Repo for source"</title>
			<link>https://www.k-wave.org/forum/topic/github-repo-for-source#post-8887</link>
			<pubDate>Wed, 02 Aug 2023 15:03:23 +0000</pubDate>
			<dc:creator>f841r</dc:creator>
			<guid isPermaLink="false">8887@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hey,&#60;/p&#62;
&#60;p&#62;Would it be possible to put the C++ source code on Github, like you did it with the toolbox?&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Fabian
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tnie on "Binary not produced"</title>
			<link>https://www.k-wave.org/forum/topic/binary-not-produced#post-8885</link>
			<pubDate>Wed, 02 Aug 2023 01:12:31 +0000</pubDate>
			<dc:creator>tnie</dc:creator>
			<guid isPermaLink="false">8885@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;For my compiler, I had to add &#60;code&#62;#include &#38;lt;string&#38;gt;&#60;/code&#62; to &#60;code&#62;Hdf5File/Hdf5File.h&#60;/code&#62;, as that's no longer implicitly included. &#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;`&#60;br /&#62;
nvcc: NVIDIA (R) Cuda compiler driver&#60;br /&#62;
Copyright (c) 2005-2023 NVIDIA Corporation&#60;br /&#62;
Built on Tue_Jul_11_02:20:44_PDT_2023&#60;br /&#62;
Cuda compilation tools, release 12.2, V12.2.128&#60;br /&#62;
Build cuda_12.2.r12.2/compiler.33053471_0&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;`
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tnie on "Binary not produced"</title>
			<link>https://www.k-wave.org/forum/topic/binary-not-produced#post-8884</link>
			<pubDate>Wed, 02 Aug 2023 01:09:27 +0000</pubDate>
			<dc:creator>tnie</dc:creator>
			<guid isPermaLink="false">8884@https://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;My bad. For some reason errors in the linker weren't printing to console. Fixed link error and the binary was produced.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
