### Basic FFTW Installation on Unix Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Standard commands to configure, build, and install FFTW on Unix-like systems using the default settings. This typically requires root privileges for the 'make install' step. ```bash ./configure make make install ``` -------------------------------- ### Building and Installing All Configurations (MSVS) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md This command builds all possible library versions defined in the makefiles and installs them into the ..\PTHREADS-BUILT directory. ```Makefile nmake all install ``` -------------------------------- ### Configure FFTW for ARM with NEON Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Example command line to configure FFTW for an ARM target architecture with NEON support enabled. It specifies the host, enables single precision and NEON, and sets the C compiler and flags appropriate for ARMv7-a with soft-float ABI. ```Shell ./configure --with-slow-timer --host=arm-linux-gnueabi \ --enable-single --enable-neon \ "CC=arm-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=softfp" ``` -------------------------------- ### Specifying MPI Libraries for FFTW (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Installation.html This command allows you to specify the necessary libraries required for linking with your MPI implementation. Use this if your MPI setup requires specific libraries to be linked manually instead of relying on a compiler wrapper. ```Shell ./configure MPILIBS=-lmpi ... ``` -------------------------------- ### Recommended Build Environment Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/FAQ.md Provides the recommended development environment setup for building applications that utilize the pthreads-win32 DLL. ```Build Configuration Use Mingw32 with the MSVCRT library to build applications that use the pthreads DLL. ``` -------------------------------- ### Run FFTW Test Programs Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Command to execute the FFTW test suite after building to verify the correctness of the compiled libraries. ```bash make check ``` -------------------------------- ### LGPL Header Block Example Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/COPYING.FSF.md This snippet provides a template for the standard header block to include in source files licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later. It includes copyright information, a brief description, and the required warranty disclaimer. ```Text Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ``` -------------------------------- ### Initializing FFTW Threads Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet demonstrates how to initialize the multi-threaded capabilities of the FFTW library. It calls dfftw_init_threads to prepare the library for threading and dfftw_plan_with_nthreads to specify the number of threads (8 in this case) that subsequent planning calls should use. ```Fortran integer iret call dfftw_init_threads(iret) call dfftw_plan_with_nthreads(8) ``` -------------------------------- ### Example: Alternative pthread_cleanup_pop(1) usage Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_cleanup_push.html Shows an alternative way to end the cleanup handler block from the previous example. Calling pthread_cleanup_pop with a non-zero argument removes and executes the handler. ```C pthread_cleanup_pop(1); ``` -------------------------------- ### Using the raw keyboard input module in a JUCE component (C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/raw-keyboard-input-module/README.md This snippet demonstrates how to initialize the raw keyboard input module within a JUCE component's constructor. It shows how to obtain an instance using `KeyboardFactory::instance`, passing the component itself to allow access to the `ComponentPeer`. It also illustrates how to install lambda functions as callbacks for key down and key up events, and mentions how to check the state of a key. ```C++ #include MyComponent::MyComponent() // extends juce::Component { // We need access to the ComponentPeer in order to distinguish // between multiple instances in a DAW, so we pass the holder of // the Keyboard instance to the factory method. The holder can be // any component in your component tree. keyboard = KeyboardFactory::instance(this); // Install callbacks keyboard->onKeyDownFn = [&](int keyCode){ keyEvent(juce::KeyEvent(keyCode, true)); }; keyboard->onKeyUpFn = [&](int keyCode){ keyEvent(juce::KeyEvent(keyCode, false)); }; // or call this in a juce::Timer instead keyboard->isKeyDown(keyCode); } ``` -------------------------------- ### Configuring FFTW with MPI (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Installation.html This command configures FFTW to include support for distributed-memory computations using MPI. It enables the compilation and installation of the necessary MPI libraries and header files alongside the standard FFTW libraries. ```Shell ./configure --enable-mpi ... ``` -------------------------------- ### Fexpr~ Example set x# Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/vanilla/expr-family.md This is a concrete example demonstrating the 'set x#' method. It sets the past values for the second input buffer (x2), specifically setting x2[-1] to 3.4 and x2[-2] to 0.4. ```Pure Data Expr Syntax "set x2 3.4 0.4" ``` -------------------------------- ### Fexpr~ Example set (outputs) Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/vanilla/expr-family.md This is a concrete example demonstrating the 'set' method for multiple outputs. It sets the most recent past value (index -1) for the first three output buffers: y1[-1] to 0.1, y2[-1] to 2.2, and y3[-1] to 0.4. ```Pure Data Expr Syntax "set 0.1 2.2 0.4" ``` -------------------------------- ### Configure FFTW with Specific Fortran Compiler Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/FAQ/fftw-faq.html/section2.html Explains how to use the configure script to specify a particular Fortran compiler (represented by 'foobar') when installing FFTW, which is necessary if the default detected compiler is incompatible. ```Shell ./configure F77=foobar ``` -------------------------------- ### Run All Compatibility Tests Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Execute the complete test suite for all DLL and static library compatibility variants (GC, GCE). Examples show running without architecture specified or explicitly for 64-bit and 32-bit architectures with MinGW64. ```Shell $ make all-tests $ make all-tests ARCH=-m64 $ make all-tests ARCH=-m32 ``` -------------------------------- ### Performing 3D Complex In-place DFT using FFTW C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This C snippet illustrates how to perform a three-dimensional complex-to-complex DFT in-place using FFTW. It declares a 3D complex array, creates a plan using fftw_plan_dft_3d with the same array for input and output, executes the plan, and destroys it. ```C fftw_complex arr[L][M][N]; fftw_plan plan; plan = fftw_plan_dft_3d(L,M,N, arr,arr, FFTW_FORWARD, FFTW_ESTIMATE); fftw_execute(plan); fftw_destroy_plan(plan); ``` -------------------------------- ### Clean FFTW Build Directory Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Command to remove all generated files from a previous configuration or build attempt, ensuring a clean state before trying again. ```bash make distclean ``` -------------------------------- ### Fexpr~ Example set y# Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/vanilla/expr-family.md This is a concrete example demonstrating the 'set y#' method. It sets the past values for the third output buffer (y3), specifically setting y3[-1] to 1.1, y3[-2] to 3.3, and y3[-3] to 4.5. ```Pure Data Expr Syntax "set y3 1.1 3.3 4.5" ``` -------------------------------- ### Specify C Compiler for FFTW Configuration Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Use the configure script to explicitly set the C compiler to be used for building FFTW, overriding the default detection. ```bash ./configure CC="__" ``` -------------------------------- ### Include Header and Function Signatures (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/sched_get_priority_max.html This snippet shows the required header file to include and the function prototypes for sched_get_priority_max and sched_get_priority_min. These functions take an integer representing the scheduling policy as input. ```C #include int sched_get_priority_max(int policy); int sched_get_priority_min(int policy); ``` -------------------------------- ### Creating a new thread using pthread_create in C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_create.html This snippet shows the function signature for `pthread_create`, which is used to create a new thread of control. It requires including the `` header. The function takes arguments for the thread identifier pointer, thread attributes, the start routine function, and an argument for the start routine. ```C #include int pthread_create(pthread_t * thread, pthread_attr_t * attr, void * (*start_routine)(void *), void * arg); ``` -------------------------------- ### Performing 1D Complex DFT using FFTW C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This C snippet demonstrates how to perform a one-dimensional complex-to-complex Discrete Fourier Transform (DFT) using the FFTW library. It involves declaring input and output arrays, creating a plan for the transform, executing the plan, and destroying the plan to free resources. ```C fftw_complex in[N], out[N]; fftw_plan plan; plan = fftw_plan_dft_1d(N,in,out,FFTW_FORWARD,FFTW_ESTIMATE); fftw_execute(plan); fftw_destroy_plan(plan); ``` -------------------------------- ### Copyright Disclaimer Sample Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/COPYING.FSF.md This snippet provides a sample text for a copyright disclaimer that an employer or school might sign to disclaim copyright interest in a library written by an employee or student. It includes placeholders for the organization name, library name, author, and signature details. ```Text Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice ``` -------------------------------- ### Specify CFLAGS for FFTW Configuration Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-on-Unix.html Use the configure script to explicitly set the C compiler flags (CFLAGS) for building FFTW, useful for optimization or troubleshooting specific system issues. ```bash ./configure CFLAGS="__" ``` -------------------------------- ### Performing 3D Complex In-place DFT using FFTW Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet provides the equivalent of the C 3D complex in-place DFT using the FFTW Fortran interface. It declares a 3D complex array, calls dfftw_plan_dft_3d for an in-place transform (passing the same array for input and output), executes with dfftw_execute_dft, and destroys the plan. ```Fortran double complex arr dimension arr(L,M,N) integer*8 plan call dfftw_plan_dft_3d(plan, L,M,N, arr,arr, & FFTW_FORWARD, FFTW_ESTIMATE) call dfftw_execute_dft(plan, arr, arr) call dfftw_destroy_plan(plan) ``` -------------------------------- ### Performing 1D Real-to-Complex DFT using FFTW Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet demonstrates how to perform a one-dimensional real-to-complex DFT using FFTW. It declares a real input array and a complex output array (with the first dimension halved), creates a plan with dfftw_plan_dft_r2c_1d, executes with dfftw_execute_dft_r2c, and destroys the plan. ```Fortran double precision in dimension in(N) double complex out dimension out(N/2 + 1) integer*8 plan call dfftw_plan_dft_r2c_1d(plan,N,in,out,FFTW_ESTIMATE) call dfftw_execute_dft_r2c(plan, in, out) call dfftw_destroy_plan(plan) ``` -------------------------------- ### Performing a 2D Complex DFT with FFTW MPI Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/2d-MPI-example.html This C code snippet demonstrates the basic workflow for computing a 2D complex DFT on a distributed array using FFTW's MPI interface. It covers MPI and FFTW MPI initialization, determining local data size, allocating memory, creating a plan, initializing the local data portion, executing the transform, destroying the plan, and finalizing MPI. ```C #include int main(int argc, char **argv) { const ptrdiff_t N0 = ..., N1 = ...; fftw_plan plan; fftw_complex *data; ptrdiff_t alloc_local, local_n0, local_0_start, i, j; MPI_Init(&argc, &argv); fftw_mpi_init(); /* get local data size and allocate */ alloc_local = fftw_mpi_local_size_2d(N0, N1, MPI_COMM_WORLD, &local_n0, &local_0_start); data = fftw_alloc_complex(alloc_local); /* create plan for in-place forward DFT */ plan = fftw_mpi_plan_dft_2d(N0, N1, data, data, MPI_COMM_WORLD, FFTW_FORWARD, FFTW_ESTIMATE); /* initialize data to some function my_function(x,y) */ for (i = 0; i < local_n0; ++i) for (j = 0; j < N1; ++j) data[i*N1 + j] = my_function(local_0_start + i, j); /* compute transforms, in-place, as many times as desired */ fftw_execute(plan); fftw_destroy_plan(plan); MPI_Finalize(); } ``` -------------------------------- ### FFTW C Example: Three Contiguous 2D DFTs in Batch Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Advanced-Complex-DFTs.html This example plans three (howmany=3) 2D complex DFTs of size 5x6. Each 5x6 array is contiguous (stride=1), and they are stored sequentially in memory. The distance (dist) between the start of one array and the next is the total size of one array (5*6=30). ```C int rank = 2; int n[] = {5, 6}; int howmany = 3; int idist = odist = n[0]*n[1]; /* = 30, the distance in memory between the first element of the first array and the first element of the second array */ int istride = ostride = 1; /* array is contiguous in memory */ int *inembed = n, *onembed = n; ``` -------------------------------- ### Configuring FFTW with Thread Support (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Installation-and-Supported-Hardware_002fSoftware.html To build FFTW with multi-threading capabilities, include the appropriate flags when running the configure script. Use `--enable-threads` for POSIX/Win32 threads or `--enable-openmp` for OpenMP threads. Both can be enabled simultaneously, but only one threading library can be linked into a program at runtime. ```Shell configure --enable-threads ``` ```Shell configure --enable-openmp ``` ```Shell configure --enable-threads --enable-openmp ``` -------------------------------- ### Synopsis for pthread_setschedparam and pthread_getschedparam (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_setschedparam.html Includes the necessary header file and provides the function signatures for pthread_setschedparam and pthread_getschedparam, used to set and get thread scheduling policy and parameters respectively. ```C #include int pthread_setschedparam(pthread_t target_thread, int policy, const struct sched_param *param); int pthread_getschedparam(pthread_t target_thread, int *policy, struct sched_param *param); ``` -------------------------------- ### Get Local Size for One-Dimensional FFTW MPI Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/MPI-Data-Distribution-Functions.html These functions are specifically for one-dimensional transforms, providing the local size and starting index for both the input and output arrays on each process. They support batched transforms via the 'howmany' parameter. ```C ptrdiff_t fftw_mpi_local_size_1d( ptrdiff_t n0, MPI_Comm comm, int sign, unsigned flags, ptrdiff_t *local_ni, ptrdiff_t *local_i_start, ptrdiff_t *local_no, ptrdiff_t *local_o_start); ``` ```C ptrdiff_t fftw_mpi_local_size_many_1d( ptrdiff_t n0, ptrdiff_t howmany, MPI_Comm comm, int sign, unsigned flags, ptrdiff_t *local_ni, ptrdiff_t *local_i_start, ptrdiff_t *local_no, ptrdiff_t *local_o_start); ``` -------------------------------- ### FFTW C Example: Batch 1D DFTs on Columns of 2D Array Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Advanced-Complex-DFTs.html This example plans three (howmany=3) 1D complex DFTs of length 10. These transforms are applied to the columns of a 2D array with 10 rows and 3 columns. The distance (dist) between the start of one column and the next is 1 (the row stride). The stride within each column is 3 (the number of rows), as elements in the same column are separated by 3 memory locations. ```C int rank = 1; /* not 2: we are computing 1d transforms */ int n[] = {10}; /* 1d transforms of length 10 */ int howmany = 3; int idist = odist = 1; int istride = ostride = 3; /* distance between two elements in the same column */ int *inembed = n, *onembed = n; ``` -------------------------------- ### Displaying NMAKE Help Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Run this command from the source directory to display help information for the nmake build tool. ```Makefile $ nmake ``` -------------------------------- ### Performing 1D Complex DFT using FFTW Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet shows the equivalent of the C 1D complex DFT using the FFTW Fortran interface. It declares complex arrays and an integer*8 variable for the plan, calls dfftw_plan_dft_1d to create the plan (receiving it as the first argument), executes the transform with dfftw_execute_dft, and destroys the plan. ```Fortran double complex in, out dimension in(N), out(N) integer*8 plan call dfftw_plan_dft_1d(plan,N,in,out,FFTW_FORWARD,FFTW_ESTIMATE) call dfftw_execute_dft(plan, in, out) call dfftw_destroy_plan(plan) ``` -------------------------------- ### Build and Run Specific Tests (with dependencies) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Navigate to the 'tests' directory and use make to build and run a list of specified tests, including their prerequisite tests defined in tests\runorder.mk. ```Shell $ cd tests $ make GC TESTS="foo bar" ``` -------------------------------- ### Get Local Size for Transposed Multidimensional FFTW MPI Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/MPI-Data-Distribution-Functions.html These functions are used for FFTW_MPI_TRANSPOSED_OUT plans. In addition to the local size and first dimension details, they also return the local starting index and size for the first dimension of the transposed output array. ```C ptrdiff_t fftw_mpi_local_size_2d_transposed(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start); ``` ```C ptrdiff_t fftw_mpi_local_size_3d_transposed(ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start); ``` ```C ptrdiff_t fftw_mpi_local_size_transposed(int rnk, const ptrdiff_t *n, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start); ``` -------------------------------- ### Specifying MPI Library and Include Paths for FFTW (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Installation.html Use this command to provide the configure script with the non-standard locations of your MPI libraries and header files. LDFLAGS specifies library paths (-L), and CPPFLAGS specifies include paths (-I), ensuring the compiler and linker can find the necessary MPI components. ```Shell ./configure LDFLAGS=-L/path/to/mpi/libs CPPFLAGS=-I/path/to/mpi/include ... ``` -------------------------------- ### Get Local Sizes for 3D Transposed Data (FFTW MPI C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Transposed-distributions.html This function retrieves the local size and starting index for both the original (non-transposed) and transposed data distributions for a 3D array in an MPI environment. It is useful when planning or analyzing transforms with FFTW_MPI_TRANSPOSED_OUT or FFTW_MPI_TRANSPOSED_IN flags. ```C ptrdiff_t fftw_mpi_local_size_3d_transposed( ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start); ``` -------------------------------- ### Checking FFTW Planner Threads Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet shows how to query the number of threads that the FFTW planner is currently configured to use. It calls the dfftw_planner_nthreads subroutine, which returns the current thread count in the integer variable iret. ```Fortran integer iret call dfftw_planner_nthreads(iret) ``` -------------------------------- ### Performing 2D Real-to-Complex DFT using FFTW Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Fortran-Examples.html This Fortran snippet shows how to perform a two-dimensional real-to-complex DFT out-of-place using FFTW. It declares a real input array and a complex output array (with the first dimension halved), creates a plan with dfftw_plan_dft_r2c_2d, executes with dfftw_execute_dft_r2c, and destroys the plan. ```Fortran double precision in dimension in(M,N) double complex out dimension out(M/2 + 1, N) integer*8 plan call dfftw_plan_dft_r2c_2d(plan,M,N,in,out,FFTW_ESTIMATE) call dfftw_execute_dft_r2c(plan, in, out) call dfftw_destroy_plan(plan) ``` -------------------------------- ### Configuring Build with CMake and Visual Studio Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/NEWS.md This command demonstrates how to create a build directory, navigate into it, and configure the project using CMake with the Visual Studio 2019 generator. This is used to test stand-alone builds. ```Shell mkdir b && cd b && cmake -G "Visual Studio 16 2019" .. ``` -------------------------------- ### Get Local Size for Basic Multidimensional FFTW MPI Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/MPI-Data-Distribution-Functions.html These functions return the total number of elements a process needs to allocate for a multidimensional array and provide the local starting index and size for the first dimension. They are used before plan creation to determine memory requirements. ```C ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); ``` ```C ptrdiff_t fftw_mpi_local_size_3d(ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); ``` ```C ptrdiff_t fftw_mpi_local_size(int rnk, const ptrdiff_t *n, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); ``` -------------------------------- ### Build Plugdata Project with CMake (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/README.md This sequence of shell commands outlines the standard process for building the Plugdata project. It involves cloning the repository recursively to include submodules, creating and navigating into a build directory, configuring the build using CMake (with optional generator specification), and finally compiling the project. ```shell git clone --recursive https://github.com/plugdata-team/plugdata.git cd plugdata mkdir build && cd build cmake .. (the generator can be specified using -G"Unix Makefiles", -G"XCode" or -G"Visual Studio 16 2019" -A x64) cmake --build . ``` -------------------------------- ### Getting 2D Local Data Size (Basic) - FFTW MPI - C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Basic-and-advanced-distribution-interfaces.html This function determines the local data distribution and required allocation size for a 2D complex-DFT on a specific MPI process. It takes the total dimensions (`n0`, `n1`) and the MPI communicator (`comm`), returning the local number of rows (`local_n0`), the starting row index (`local_0_start`), and the total number of elements to allocate. ```C ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); ``` -------------------------------- ### Getting Multidimensional Local Data Size (Advanced) - FFTW MPI - C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Basic-and-advanced-distribution-interfaces.html This advanced function calculates the local data distribution and allocation size for a multidimensional transform (`rnk > 1`). It supports multiple transforms (`howmany`) and allows specifying a custom block size (`block0`). It returns the local size (`local_n0`), start index (`local_0_start`), and total elements to allocate, similar to the basic interface. ```C ptrdiff_t fftw_mpi_local_size_many(int rnk, const ptrdiff_t *n, ptrdiff_t howmany, ptrdiff_t block0, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); ``` -------------------------------- ### Building Plugdata Test Suite with Watcom Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.Watcom.md Commands to build the Plugdata test suite using the Watcom wmake utility. Various targets are available for different configurations and benchmarking. ```shell wmake -f Wmakefile clean WC ``` ```shell wmake -f Wmakefile clean WCX ``` ```shell wmake -f Wmakefile clean WCE ``` ```shell wmake -f Wmakefile clean WC-bench ``` ```shell wmake -f Wmakefile clean WCX-bench ``` ```shell wmake -f Wmakefile clean WCE-bench ``` -------------------------------- ### Printing FFTW Plan to File (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Using-Plans.html Outputs a detailed, "nerd-readable" representation of an FFTW plan to a specified file stream. Useful for debugging and understanding the plan structure. ```C void fftw_fprint_plan(const fftw_plan plan, FILE *output_file); ``` -------------------------------- ### Get Thread Name pthreads-win32 C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md This function gets the name of a thread. It is provided for compatibility. ```C int pthread_getname_np(pthread_t thr, char *name, int len); ``` -------------------------------- ### Run Static Library Tests (MinGW32) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Navigate to the 'tests' directory and run the test suite using the static library built with the MinGW32 toolchain. ```Shell cd tests make clean GC-static ``` -------------------------------- ### Printing FFTW Plan to Stdout (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Using-Plans.html Outputs a detailed, "nerd-readable" representation of an FFTW plan to the standard output stream (`stdout`). Useful for quick debugging. ```C void fftw_print_plan(const fftw_plan plan); ``` -------------------------------- ### Changing Directory to Tests Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Navigate into the 'tests' subdirectory to build and run individual tests or the test suite. ```Command Line $ cd tests ``` -------------------------------- ### Example: Using cleanup handlers with mutex in deferred cancellation Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_cleanup_push.html Demonstrates the basic pattern for using pthread_cleanup_push and pthread_cleanup_pop to ensure a mutex is unlocked if a thread is cancelled while holding the lock. This example is safe in deferred cancellation mode. ```C pthread_cleanup_push(pthread_mutex_unlock, (void *) &mut); pthread_mutex_lock(&mut); /* do some work */ pthread_mutex_unlock(&mut); pthread_cleanup_pop(0); ``` -------------------------------- ### Specifying MPI Compiler for FFTW (Shell) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Installation.html Use this command to explicitly tell the FFTW configure script which MPI compiler wrapper (like mpicc) should be used for compiling MPI-related code. This is useful if the script cannot automatically detect the correct compiler or if multiple MPI implementations are present. ```Shell ./configure MPICC=mpicc ... ``` -------------------------------- ### Performing a Distributed 2D Complex DFT In-Place using FFTW MPI Fortran Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Fortran-Interface.html This Fortran snippet demonstrates how to perform a distributed L x M complex Discrete Fourier Transform (DFT) in-place using the FFTW MPI interface. It shows how to get the local data size, allocate memory using FFTW's routines, create an MPI plan for a 2D DFT, initialize the distributed data, execute the transform, and clean up resources. Note the dimension reversal for Fortran arrays and the use of `integer(C_INTPTR_T)` for sizes and offsets. Requires MPI and `fftw_mpi_init` to be initialized beforehand. ```Fortran use, intrinsic :: iso\_c\_binding include 'fftw3-mpi.f03' integer(C\_INTPTR\_T), parameter :: L = ... integer(C\_INTPTR\_T), parameter :: M = ... type(C\_PTR) :: plan, cdata complex(C\_DOUBLE\_COMPLEX), pointer :: data(:,:) integer(C\_INTPTR\_T) :: i, j, alloc\_local, local\_M, local\_j\_offset ! get local data size and allocate (note dimension reversal) alloc\_local = fftw\_mpi\_local\_size\_2d(M, L, MPI\_COMM\_WORLD, & local\_M, local\_j\_offset) cdata = fftw\_alloc\_complex(alloc\_local) call c\_f\_pointer(cdata, data, \[L,local\_M\]) ! create MPI plan for in-place forward DFT (note dimension reversal) plan = fftw\_mpi\_plan\_dft\_2d(M, L, data, data, MPI\_COMM\_WORLD, & FFTW\_FORWARD, FFTW\_MEASURE) ! initialize data to some function my\_function(i,j) do j = 1, local\_M do i = 1, L data(i, j) = my\_function(i, j + local\_j\_offset) end do end do ! compute transform (as many times as desired) call fftw\_mpi\_execute\_dft(plan, data, data) call fftw\_destroy\_plan(plan) call fftw\_free(cdata) ``` -------------------------------- ### Includes, Enum, and Global State - ACE C++ (tennisb.cpp) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.CV.md Includes necessary ACE headers for synchronization and threading. Defines an enum for game states and declares global pointers for the game state variable, a mutex, and a condition variable. This appears to be a duplicate or slightly modified version of the setup in tennis.cpp. ```C++ #include "ace/Synch.h" #include "ace/Thread.h" enum GAME_STATE { START_GAME, PLAYER_A, // Player A playes the ball PLAYER_B, // Player B playes the ball GAME_OVER, ONE_PLAYER_GONE, BOTH_PLAYERS_GONE }; enum GAME_STATE eGameState; ACE_Mutex* pmtxGameStateLock; ACE_Condition< ACE_Mutex >* pcndGameStateChange; ``` -------------------------------- ### Build and Run Specific Tests (without dependencies) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Change to the 'tests' directory and use make with NO_DEPS=1 to build and run only the explicitly listed tests, skipping any prerequisites. ```Shell $ cd tests $ make GC NO_DEPS=1 TESTS="foo bar" ``` -------------------------------- ### Example Custom Threading Callback (OpenMP, C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Usage-of-Multi_002dthreaded-FFTW.html An example implementation of the parallel_loop callback function using OpenMP. This function distributes the execution of the provided work function across multiple threads using an OpenMP parallel for loop. ```C void parallel_loop(void *(*work)(char *), char *jobdata, size_t elsize, int njobs, void *data) { #pragma omp parallel for for (int i = 0; i < njobs; ++i) work(jobdata + elsize * i); } ``` -------------------------------- ### Implementing Average Filter with Fexpr~ (Explicit Index) - Pure Data Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/vanilla/expr-family.md Demonstrates how to use the fexpr~ object in Pure Data to create a simple FIR filter. This example calculates the average of the current input sample ($x1[0]) and the previous input sample ($x1[-1]) from the first inlet ($x1). The result is the output signal. ```Pure Data fexpr~ ($x1[0]+$x1[-1])/2 ``` -------------------------------- ### Importing FFTW MPI Wisdom (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/FFTW-MPI-Wisdom.html Demonstrates how to import FFTW wisdom from a file in an MPI program. Process 0 reads the wisdom from the specified file after initializing FFTW MPI, and then broadcasts it to all other processes using `fftw_mpi_broadcast_wisdom`. Requires `fftw_mpi_init` to be called first. ```C { int rank; fftw_mpi_init(); MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank == 0) fftw_import_wisdom_from_filename("mywisdom"); fftw_mpi_broadcast_wisdom(MPI_COMM_WORLD); } ``` -------------------------------- ### Adding Standard Search Path with declare in Pure Data Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/vanilla/declare.md This snippet demonstrates using the 'declare' object with the '-stdpath' flag to add a directory relative to Pd's standard 'extra' folder to the search path. This is useful for accessing files installed within the Pd installation directory. ```Pure Data declare -stdpath stillmore ``` -------------------------------- ### Prepare Build Environment (GNU Autotools) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Run the standard GNU autotools commands to generate or update the configuration header and Makefiles before proceeding with the build. ```Shell $ autoheader $ autoconf $ ./configure $ make realclean all-tests ``` -------------------------------- ### Running Tests for a Specific Configuration (MSVS) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md From the 'tests' directory, run this command to build and execute the test suite for a specified configuration (e.g., VC). ```Makefile $ nmake VC ``` -------------------------------- ### Importing System Wisdom (FFTW C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Wisdom-Import.html Imports wisdom from the implementation-defined standard system wisdom file (e.g., /etc/fftw/wisdom). Returns 1 on success and 0 on failure. ```C int fftw_import_system_wisdom(void); ``` -------------------------------- ### Get and Set Barrier Process-Shared Attribute (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_barrierattr_setpshared.html These C functions are used to retrieve (get) and set the process-shared attribute within a pthread barrier attributes object. The attribute determines if the barrier can be used by threads in different processes (PTHREAD_PROCESS_SHARED) or only within the same process (PTHREAD_PROCESS_PRIVATE). Requires including the header. ```c #include int pthread_barrierattr_getpshared(const pthread_barrierattr_t * restrict attr, int *restrict pshared); int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared); ``` -------------------------------- ### FFTW C Example: Single Contiguous 2D DFT Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Advanced-Complex-DFTs.html This example demonstrates planning a single (howmany=1) 2D complex DFT of size 5x6 using fftw_plan_many_dft. Since howmany is 1, the dist parameters are unused (set to 0). The stride is 1 because the array is contiguous in memory. The embed parameters are set to n, indicating the logical and physical dimensions are the same. ```C int rank = 2; int n[] = {5, 6}; int howmany = 1; int idist = odist = 0; /* unused because howmany = 1 */ int istride = ostride = 1; /* array is contiguous in memory */ int *inembed = n, *onembed = n; ``` -------------------------------- ### Synopsis: pthread_cleanup_push and pthread_cleanup_pop Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_cleanup_push.html Includes the necessary header file for pthreads functions and shows the standard C function signatures for pthread_cleanup_push and pthread_cleanup_pop. ```C #include void pthread_cleanup_push(void (*routine) (void *), void *arg); void pthread_cleanup_pop(int execute); ``` -------------------------------- ### Synopsis of pthread_barrierattr functions in C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_barrierattr_init.html This snippet shows the function signatures for pthread_barrierattr_destroy and pthread_barrierattr_init, including the necessary header file. ```C #include int pthread_barrierattr_destroy(pthread_barrierattr_t *attr); int pthread_barrierattr_init(pthread_barrierattr_t *attr); ``` -------------------------------- ### Get Thread Affinity pthreads-win32 C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md This function manipulates the CPU affinity of a thread. It is provided for compatibility with libgcc-based pthreads implementations. ```C int pthread_getaffinity_np (pthread_t thread, size_t cpusetsize, cpu_set_t * cpuset); ``` -------------------------------- ### Main Game Initialization and Control (C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.CV.md This is the main function that initializes mutex and condition variables, sets the initial game state, spawns player threads (A and B), allows them to play for a duration, introduces "noise" (broadcasts), sets the game over state, signals players to stop, waits for them to finish, and performs cleanup. ```C++ int main (int, ACE_TCHAR *[]) { pmtxGameStateLock = new ACE_Mutex(); pcndGameStateChange = new ACE_Condition< ACE_Mutex >( *pmtxGameStateLock ); // Set initial state eGameState = START_GAME; // Create players ACE_Thread::spawn( playerA ); ACE_Thread::spawn( playerB ); // Give them 5 sec. to play Sleep( 5000 );//sleep( 5 ); // Make some noise pmtxGameStateLock->acquire(); cout << endl << "---Noise ON..." << endl; pmtxGameStateLock->release(); for ( int i = 0; i < 100000; i++ ) pcndGameStateChange->broadcast(); cout << endl << "---Noise OFF" << endl; // Set game over state pmtxGameStateLock->acquire(); eGameState = GAME_OVER; cout << endl << "---Stopping the game..." << endl; // Let them know pcndGameStateChange->broadcast(); // Wait for players to stop do { pcndGameStateChange->wait(); } while ( eGameState < BOTH_PLAYERS_GONE ); // Cleanup cout << endl << "GAME OVER" << endl; pmtxGameStateLock->release(); delete pcndGameStateChange; delete pmtxGameStateLock; return 0; } ``` -------------------------------- ### Run Static Library Tests (MSVC) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Change to the 'tests' directory and execute the test suite using the static library built with the MSVC toolchain. ```Shell cd tests nmake clean VC-static ``` -------------------------------- ### Getting Unique ID for pthreads-win32 Thread (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md Returns a unique 64-bit integer number associated with the specified pthreads-win32 thread handle. ```C/C++ __int64 pthread_getunique_np (pthread_t thr) ``` -------------------------------- ### Get Thread Attribute Affinity pthreads-win32 C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md This function manipulates the CPU affinity attribute of a thread. It is provided for compatibility with libgcc-based pthreads implementations. ```C int pthread_attr_getaffinity_np (pthread_attr_t * attr, size_t cpusetsize, cpu_set_t * cpuset); ``` -------------------------------- ### Build Static Library (MinGW32) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Create the static linked library (libpthreadGCn.a) for the MinGW32 toolchain using make with the GC-static target. ```Shell make clean GC-static ``` -------------------------------- ### Run Tests from Tests Directory Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md Change the current directory to 'tests' and run the test suite for a specific library variant (e.g., GC) using make. ```Shell $ cd tests $ make GC ``` -------------------------------- ### Synopsis for pthread_once - C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_once.html This snippet shows the standard C synopsis for using pthread_once. It includes the declaration of the pthread_once_t control variable, which must be statically initialized with PTHREAD_ONCE_INIT, and the function signature for pthread_once itself, which takes a pointer to the control variable and a pointer to the initialization routine. ```C pthread_once_t once_control = PTHREAD_ONCE_INIT; int pthread_once(pthread_once_t *once_control, void (*init_routine) (void)); ``` -------------------------------- ### Get Scheduling Policy Synopsis (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/sched_getscheduler.html This snippet shows the required header file and the function signature for the sched_getscheduler function, which is used to retrieve the scheduling policy of a specified process. ```C #include int sched_getscheduler(pid_t pid); ``` -------------------------------- ### Initializing FFTW for Combined MPI and Threads (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Combining-MPI-and-Threads.html This C code snippet demonstrates the correct initialization sequence for using FFTW with both MPI and threads. It shows how to use MPI_Init_thread to request thread support from MPI, check the provided level, and then initialize FFTW's thread and MPI support in the required order. It also illustrates how to conditionally use thread-specific FFTW functions based on the available thread support. ```C int threads_ok; int main(int argc, char **argv) { int provided; MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided); threads_ok = provided >= MPI_THREAD_FUNNELED; if (threads_ok) threads_ok = fftw_init_threads(); fftw_mpi_init(); ... if (threads_ok) fftw_plan_with_nthreads(...); ... MPI_Finalize(); } ``` -------------------------------- ### Getting pthreads-win32 Mutex Kind (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md This routine is included for Linux compatibility and is equivalent to pthread_mutexattr_gettype. It retrieves the kind (type) of a mutex attribute object into the provided integer pointer. ```C/C++ int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind) ``` -------------------------------- ### Importing System Wisdom (FFTW C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Caveats-in-Using-Wisdom.html This function attempts to load pre-computed optimization plans (wisdom) from a standard system-wide location, typically `/etc/fftw/wisdom` on Unix-like systems. Importing system wisdom can potentially improve performance by using pre-optimized plans, but users should be aware that these plans might be sub-optimal if the current execution environment or program binary differs significantly from when the wisdom was generated. ```C int fftw_import_system_wisdom(void); ``` -------------------------------- ### Import Wisdom from File - FFTW - C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Words-of-Wisdom_002dSaving-Plans.html Imports FFTW wisdom from a specified file, adding it to the current accumulation of wisdom. This restores previously saved optimized plans. The function returns non-zero on success. ```C int fftw_import_wisdom_from_filename(const char *filename); ``` -------------------------------- ### Get Thread Unique Sequence Number in C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_getunique_np.html Includes the necessary header and provides the function signature for pthread_getunique_np, which returns a unique 64-bit sequence number for a specified thread. ```C #include unsigned long long pthread_getunique_np(pthread_t thread); ``` -------------------------------- ### Instantiating xgate2~ Object in Pure Data Source: https://github.com/plugdata-team/plugdata/blob/develop/Resources/Documentation/ELSE/xgate2~.md This snippet shows the basic representation of the 'xgate2~' object as it appears in a Pure Data patch. It represents an instance of the object ready to be connected to other objects. ```Pure Data [xgate2~] ``` -------------------------------- ### Get Current Number of Threads for FFTW Planning (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/fftw3/doc/html/Usage-of-Multi_002dthreaded-FFTW.html Returns the number of threads that FFTW is currently configured to use for plan creation. This value is set by the most recent call to fftw_plan_with_nthreads. ```C int fftw_planner_nthreads(void); ``` -------------------------------- ### POSIX Semaphore Header and Functions (C) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.CV.md Includes the header file for POSIX semaphores and lists the primary functions for controlling, getting, and performing operations on semaphores as defined in . ```C int semctl(int, int, int, ...); int semget(key_t, int, int); int semop(int, struct sembuf *, size_t); ``` -------------------------------- ### Cleaning and Building Specific Configurations (MSVS) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md These commands clean the build environment and build specific library configurations (DLL, static, debug) for VC, VCE, and VSE variants. ```Makefile nmake clean VC ``` ```Makefile nmake clean VC-debug ``` ```Makefile nmake clean VC-static ``` ```Makefile nmake clean VC-static-debug ``` ```Makefile nmake clean VCE ``` ```Makefile nmake clean VCE-debug ``` ```Makefile nmake clean VCE-static ``` ```Makefile nmake clean VCE-static-debug ``` ```Makefile nmake clean VSE ``` ```Makefile nmake clean VSE-debug ``` ```Makefile nmake clean VSE-static ``` ```Makefile nmake clean VSE-static-debug ``` -------------------------------- ### Getting Win32 Thread ID from pthreads-win32 (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md Returns the native Windows thread ID corresponding to a given POSIX thread handle. This is only valid under specific build configurations and returns 0 otherwise. ```C/C++ DWORD pthread_getw32threadid_np (pthread_t thread) ``` -------------------------------- ### Getting Win32 Thread Handle from pthreads-win32 (C/C++) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md Returns the native Windows thread handle corresponding to a given POSIX thread handle. Applications can use this handle to set Windows-specific thread attributes. ```C/C++ HANDLE pthread_getw32threadhandle_np(pthread_t thread); ``` -------------------------------- ### Synopsis - pthread_getconcurrency and pthread_setconcurrency - C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/manual/pthread_setconcurrency.html This snippet shows the required header file and the function signatures for pthread_getconcurrency and pthread_setconcurrency. These functions are used to get and set a hint for the desired level of concurrency for unbound threads. ```C #include int pthread_getconcurrency(void); int pthread_setconcurrency(int new_level); ``` -------------------------------- ### Building Plugdata Library with Watcom Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.Watcom.md Commands to build the Plugdata library using the Watcom wmake utility. Different targets produce different versions of the library (e.g., pthreadWC.dll, pthreadWCE.dll), potentially with or without inlining. ```shell wmake -f Wmakefile clean WC ``` ```shell wmake -f Wmakefile clean WC-inlined ``` ```shell wmake -f Wmakefile clean WCE ``` ```shell wmake -f Wmakefile clean WCE-inlined ``` -------------------------------- ### Get Number of Processors pthreads-win32 C Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.NONPORTABLE.md This routine, found on HPUX systems, returns the number of processors available to the process. This may be lower than the total system processors depending on the process's affinity mask. ```C int pthread_num_processors_np (void) ``` -------------------------------- ### Pseudocode: Initial Condition Wait Steps Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.CV.md Illustrates the initial steps of a condition variable wait, including entering a critical section, incrementing the waiter count, releasing the mutex, and waiting on a semaphore. It highlights a potential race condition where a signaling thread might overtake the waiting thread after the mutex is released. ```Pseudocode { /** Critical Section inc cond.waiters_count } /* /* Atomic only if using Win32 SignalObjectAndWait /* cond.mtx.release Sleep( 1 ); // Win32 /*** ^^-- A THREAD WHICH DID SIGNAL MAY ACQUIRE THE MUTEX, /*** GO INTO WAIT ON THE SAME CONDITION AND OVERTAKE /*** ORIGINAL WAITER(S) CONSUMING ITS OWN SIGNAL! cond.sem.wait ``` -------------------------------- ### Cleaning and Running All Tests (MSVS) Source: https://github.com/plugdata-team/plugdata/blob/develop/Libraries/pthread-win32/docs/README.md These commands clean the build environment and run the full test suite. Different options are available for exhaustive testing or specific configurations (multithreaded DLL/static). ```Makefile nmake clean all-tests ``` ```Makefile nmake -DEXHAUSTIVE clean all-tests ``` ```Makefile nmake clean all-tests-md ``` ```Makefile nmake clean all-tests-mt ```