### Example Usage of libvolk Conversion and Memory Functions (C) Source: https://www.libvolk.org/doxygen/volk_16ic_convert_32fc Demonstrates the usage of `volk_16ic_convert_32f`, `volk_get_alignment`, `volk_malloc`, and `volk_free`. This example allocates memory for input and output vectors, performs the conversion, and then frees the allocated memory. It highlights the typical workflow for using these functions. ```c int N = 10000; unsigned int alignment = volk_get_alignment(); lv_16sc_t* input = (lv_16sc_t*)volk_malloc(sizeof(lv_16sc_t)*N, alignment); lv_32fc_t* output = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); volk_16ic_convert_32f(output, input, N); volk_free(input); volk_free(output); ``` -------------------------------- ### Example: Deinterleaving Complex Numbers (C) Source: https://www.libvolk.org/doxygen/volk_32fc_deinterleave_real_64f An example demonstrating how to generate complex numbers, deinterleave their real parts using `volk_32fc_deinterleave_real_64f`, and print the results. It utilizes `volk_malloc` for memory allocation and `volk_free` for deallocation. ```c int N = 10; unsigned int alignment = volk_get_alignment(); lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); double* re = (double*)volk_malloc(sizeof(double)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ float real = 2.f * ((float)ii / (float)N) - 1.f; float imag = std::sqrt(1.f - real * real); in[ii] = lv_cmake(real, imag); } volk_32fc_deinterleave_real_64f(re, in, N); printf(" real part\n"); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %+.1g\n", ii, re[ii]); } volk_free(in); volk_free(re); ``` -------------------------------- ### VOLK: Example Usage (C) Source: https://www.libvolk.org/doxygen/volk_32f_x2_max_32f Demonstrates the usage of VOLK functions, including memory allocation, vector initialization, the volk_32f_x2_max_32f operation, and memory deallocation. This example highlights practical application of the library's features. ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment); float* decreasing = (float*)volk_malloc(sizeof(float)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = (float)ii; decreasing[ii] = 10.f - (float)ii; } volk_32f_x2_max_32f(out, increasing, decreasing, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%u] = %1.2f\n", ii, out[ii]); } volk_free(increasing); volk_free(decreasing); volk_free(out); ``` -------------------------------- ### Example: Constellation Distance Calculation (C) Source: https://www.libvolk.org/doxygen/volk_32fc_x2_s32f_square_dist_scalar_mult_32f An example demonstrating the usage of `volk_32fc_x2_s32f_square_dist_scalar_mult_32f`. It initializes a 16-QAM constellation, defines a received signal, calculates the scaled squared distances to each constellation point, and prints the results. Memory is managed using Volk's `volk_malloc` and `volk_free`. ```c int N = 16; unsigned int alignment = volk_get_alignment(); lv_32fc_t* constellation = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); lv_32fc_t* rx = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); float const_vals[] = {-3, -1, 1, 3}; unsigned int jj = 0; for(unsigned int ii = 0; ii < N; ++ii){ constellation[ii] = lv_cmake(const_vals[ii%4], const_vals[jj]); if((ii+1)%4 == 0) ++jj; } *rx = lv_cmake(0.5f, 2.f); float scale = 1.f/64.f; // 1 / constellation area volk_32fc_x2_s32f_square_dist_scalar_mult_32f(out, rx, constellation, scale, N); printf("Distance from each constellation point:\n"); for(unsigned int ii = 0; ii < N; ++ii){ printf("%.4f ", out[ii]); if((ii+1)%4 == 0) printf("\n"); } volk_free(rx); volk_free(constellation); volk_free(out); ``` -------------------------------- ### Example: Convert floats to 16-bit integers with scaling Source: https://www.libvolk.org/doxygen/volk_32f_s32f_convert_16i Demonstrates the usage of the `volk_32f_s32f_convert_32i` function. This example converts a vector of floats ranging from -1 to 1 into 16-bit integers, applying a scalar of 5.0 to maintain precision. It includes memory allocation and deallocation steps. ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment); int16_t* out = (int16_t*)volk_malloc(sizeof(int16_t)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = 2.f * ((float)ii / (float)N) - 1.f; } // Normalize by the smallest delta (0.2 in this example) float scale = 5.f; volk_32f_s32f_convert_32i(out, increasing, scale, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%u] = %i\n", ii, out[ii]); } volk_free(increasing); volk_free(out); ``` -------------------------------- ### Generic VOLK Function Example Source: https://www.libvolk.org/doxygen/volk_16i_x4_quad_max_star_16i An example demonstrating the usage of a generic VOLK function like `volk_16i_x4_quad_max_star_16i` along with memory management. ```APIDOC ## Generic VOLK Function Example ### Description This example illustrates how to use a VOLK function, potentially involving input vectors and calculating an output, followed by memory cleanup. ### Example Usage #### Method `int N = 10000; volk_16i_x4_quad_max_star_16i(); // Example VOLK function call volk_free(x); // Assuming 'x' is a pointer to allocated memory volk_free(y); // Assuming 'y' is another pointer to allocated memory ``` -------------------------------- ### Example: Deinterleave Imaginary Part (C) Source: https://www.libvolk.org/doxygen/volk_32fc_deinterleave_imag_32f Demonstrates how to generate complex numbers, extract their imaginary parts using `volk_32fc_deinterleave_imag_32f`, and print the results. This example highlights the usage of `volk_malloc`, `volk_free`, `volk_get_alignment`, and `lv_cmake` in conjunction with the deinterleaving function. ```c int N = 10; unsigned int alignment = volk_get_alignment(); lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); float* im = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ float real = 2.f * ((float)ii / (float)N) - 1.f; float imag = std::sqrt(1.f - real * real); in[ii] = lv_cmake(real, imag); } volk_32fc_deinterleave_imag_32f(im, in, N); printf(" imaginary part\n"); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %+.1f\n", ii, im[ii]); } volk_free(in); volk_free(im); ``` -------------------------------- ### Example Usage of VOLK Max Index Function (C) Source: https://www.libvolk.org/doxygen/volk_32f_index_max_32u This example demonstrates the usage of `volk_32f_index_max_32u` along with VOLK's memory management functions. It allocates memory, populates a float array with parabolic data, finds the index of the maximum value, prints the result, and then frees the allocated memory. ```c int N = 10; uint32_t alignment = volk_get_alignment(); float* in = (float*)volk_malloc(sizeof(float)*N, alignment); uint32_t* out = (uint32_t*)volk_malloc(sizeof(uint32_t), alignment); for(uint32_t ii = 0; ii < N; ++ii){ float x = (float)ii; // a parabola with a maximum at x=4 in[ii] = -(x-4) * (x-4) + 5; } volk_32f_index_max_32u(out, in, N); printf("maximum is %%1.2f at index %%u\n", in[*out], *out); volk_free(in); volk_free(out); ``` -------------------------------- ### Example: Using volk_32f_tanh_32f with Memory Management in C Source: https://www.libvolk.org/doxygen/volk_32f_tanh_32f This C code example demonstrates how to use the volk_32f_tanh_32f function to compute the approximate artanh(x) for x<1. It includes memory allocation using volk_malloc, input data generation, the tanh computation, output printing, and memory deallocation using volk_free. It also shows how to get machine alignment with volk_get_alignment. ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* in = (float*)volk_malloc(sizeof(float)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ // the approximate artanh(x) for x<1 float x = (float)ii / (float)N; in[ii] = 0.5 * std::log((1.f+x)/(1.f-x)); } volk_32f_tanh_32f(out, in, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %f\n", ii, out[ii]); } volk_free(in); volk_free(out); ``` -------------------------------- ### Example Usage of volk_64f_x2_max_64f (C) Source: https://www.libvolk.org/doxygen/volk_64f_x2_max_64f Demonstrates the practical application of the `volk_64f_x2_max_64f` function. It initializes two vectors with increasing and decreasing values, computes their element-wise maximum using the function, prints the results, and then frees the allocated memory. This example highlights the importance of using VOLK's memory management functions. ```c int N = 10; unsigned int alignment = volk_get_alignment(); double* increasing = (double*)volk_malloc(sizeof(double)*N, alignment); double* decreasing = (double*)volk_malloc(sizeof(double)*N, alignment); double* out = (double*)volk_malloc(sizeof(double)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = (double)ii; decreasing[ii] = 10.f - (double)ii; } volk_64f_x2_max_64f(out, increasing, decreasing, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%u] = %1.2g\n", ii, out[ii]); } volk_free(increasing); volk_free(decreasing); volk_free(out); ``` -------------------------------- ### Example Usage of volk_32f_log2_32f (C) Source: https://www.libvolk.org/doxygen/volk_32f_log2_32f Demonstrates how to use the `volk_32f_log2_32f` function. This example allocates memory using `volk_malloc`, populates an input vector with powers of 2, calculates their logarithms using `volk_32f_log2_32f`, prints the results, and then frees the memory with `volk_free`. ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* in = (float*)volk_malloc(sizeof(float)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ in[ii] = std::pow(2.f,((float)ii)); } volk_32f_log2_32f(out, in, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %f\n", ii, out[ii]); } volk_free(in); volk_free(out); ``` -------------------------------- ### Example: Deinterleaving Complex Numbers (C) Source: https://www.libvolk.org/doxygen/volk_32fc_deinterleave_64f_x2 An example demonstrating the usage of volk_32fc_deinterleave_64f_x2. It generates complex numbers, allocates memory using volk_malloc, performs deinterleaving, prints the results, and frees the allocated memory using volk_free. ```C int N = 10; unsigned int alignment = volk_get_alignment(); lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); double* re = (double*)volk_malloc(sizeof(double)*N, alignment); double* im = (double*)volk_malloc(sizeof(double)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ float real = 2.f * ((float)ii / (float)N) - 1.f; float imag = std::sqrt(1.f - real * real); in[ii] = lv_cmake(real, imag); } volk_32fc_deinterleave_64f_x2(re, im, in, N); printf(" re | im\n"); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %+.1g | %+.1g\n", ii, re[ii], im[ii]); } volk_free(in); volk_free(re); volk_free(im); ``` -------------------------------- ### VOLK Memory Management and Vector Addition Example (C) Source: https://www.libvolk.org/doxygen/volk_32f_s32f_add_32f This example demonstrates the usage of VOLK library functions for memory allocation, alignment retrieval, vector initialization, a scalar addition operation on a float vector, and memory deallocation. It shows how to allocate aligned memory using volk_malloc, retrieve machine alignment with volk_get_alignment, perform the addition using volk_32f_s32f_add_32f, and free the allocated memory with volk_free. The output of the operation is printed to the console. Dependencies include standard C libraries for input/output. ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = 2.f * ((float)ii / (float)N) - 1.f; } // Add addshift to each entry. float addshift = 5.0f; volk_32f_s32f_add_32f(out, increasing, addshift, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%u] = %f\n", ii, out[ii]); } volk_free(increasing); volk_free(out); ``` -------------------------------- ### Example Usage of VOLK Sum of Polynomial Function (C++) Source: https://www.libvolk.org/doxygen/volk_32f_x3_sum_of_poly_32f This C++ example demonstrates the usage of the `volk_32f_x3_sum_of_poly_32f` function. It includes setting up polynomial coefficients, generating input data, calling the VOLK function, and then calculating the approximate area by multiplying the result by the bin width. Memory is managed using `volk_malloc` and `volk_free`. ```cpp int npoints = 4096; float* coefficients = (float*)volk_malloc(sizeof(float) * 5, volk_get_alignment()); float* input = (float*)volk_malloc(sizeof(float) * npoints, volk_get_alignment()); float* result = (float*)volk_malloc(sizeof(float), volk_get_alignment()); float* cutoff = (float*)volk_malloc(sizeof(float), volk_get_alignment()); // load precomputed Taylor series coefficients coefficients[0] = 4.48168907033806f; // c1 coefficients[1] = coefficients[0] * 0.5f; // c2 coefficients[2] = coefficients[0] * 1.0f/6.0f; // c3 coefficients[3] = coefficients[0] * 1.0f/24.0f; // c4 coefficients[4] = coefficients[0]; // c0 *cutoff = -2.0; *result = 0.0f; // generate uniform input data float dx = (float)M_PI/ (float)npoints; for(unsigned int ii=0; ii < npoints; ++ii){ input[ii] = dx * (float)ii - 1.5f; } volk_32f_x3_sum_of_poly_32f(result, input, coefficients, cutoff, npoints); // multiply by bin width to get approximate area std::cout << "result is " << *result * (input[1]-input[0]) << std::endl; volk_free(coefficients); volk_free(input); volk_free(result); volk_free(cutoff); ``` -------------------------------- ### C: Example VOLK Dispatcher with Tail Case and Accumulator Source: https://www.libvolk.org/doxygen/md__home_johannes_src_volk_switch_kernels__r_e_a_d_m_e This C code provides an example of a custom VOLK kernel dispatcher for a 32-bit floating-point dot product. It optimizes for aligned or unaligned memory access for the main part of the data and then uses a separate kernel call for the tail elements, accumulating the result. ```c #include #ifdef LV_HAVE_DISPATCHER static inline void volk_32f_x2_dot_prod_32f_dispatcher(float * result, const float * input, const float * taps, unsigned int num_points) { const unsigned int num_points_r = num_points%16; const unsigned int num_points_x = num_points - num_points_r; if (volk_is_aligned(VOLK_OR_PTR(input, taps))) { volk_32f_x2_dot_prod_32f_a(result, input, taps, num_points_x); } else { volk_32f_x2_dot_prod_32f_u(result, input, taps, num_points_x); } float result_tail = 0; volk_32f_x2_dot_prod_32f_g(&result_tail, input+num_points_x, taps+num_points_x, num_points_r); *result += result_tail; } #endif //LV_HAVE_DISPATCHER ``` -------------------------------- ### Example Usage of FM Detection Source: https://www.libvolk.org/doxygen/volk_32f_s32f_32f_fm_detect_32f This C code snippet demonstrates how to set up and call the volk_32f_s32f_32f_fm_detect_32f function. It initializes the number of data points and then calls the detection function. ```c int N = 10000; // Assuming inputVector, saveValue, and outputVector are properly allocated and initialized // volk_32f_s32f_32f_fm_detect_32f(inputVector, bound, saveValue, N, outputVector); ``` -------------------------------- ### Example: Deinterleave Real Parts and Print - C Source: https://www.libvolk.org/doxygen/volk_32fc_deinterleave_real_32f Demonstrates the usage of VOLK functions to generate complex numbers, deinterleave their real parts into a float buffer, and print the results. This example utilizes `volk_get_alignment`, `volk_malloc`, `lv_cmake`, `volk_32fc_deinterleave_real_32f`, and `volk_free`. ```c int N = 10; unsigned int alignment = volk_get_alignment(); lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); float* re = (float*)volk_malloc(sizeof(float)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ float real = 2.f * ((float)ii / (float)N) - 1.f; float imag = std::sqrt(1.f - real * real); in[ii] = lv_cmake(real, imag); } volk_32fc_deinterleave_real_32f(re, in, N); printf(" real part\n"); for(unsigned int ii = 0; ii < N; ++ii){ printf("out(%i) = %+.1f\n", ii, re[ii]); } volk_free(in); volk_free(re); ``` -------------------------------- ### Overview of VOLK Kernels Source: https://www.libvolk.org/doxygen/volk_8ic_s32f_deinterleave_real_32f Provides a general overview of the purpose and functionality of VOLK kernels, highlighting specific examples. ```APIDOC ## Overview Deinterleaves the complex 8-bit char vector into just the real (I) vector, converts the samples to floats, and divides the results by the scalar factor. ### Dispatcher Prototype This section would typically contain the C/C++ prototype for the dispatcher function if available. ``` -------------------------------- ### Volk Complex Rotator Example: Tone Generation and Shifting Source: https://www.libvolk.org/doxygen/volk_32fc_s32fc_x2_rotator_32fc Demonstrates generating a tone at a normalized frequency (f=0.3) and then using the Volk complex rotator to shift its frequency to f=0.4. The example initializes the input with a DC tone (f=0) to observe signal generation. It uses `volk_malloc` for memory allocation and `volk_free` for deallocation. ```c int N = 10; unsigned int alignment = volk_get_alignment(); lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); lv_32fc_t* out = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ // Generate a tone at f=0.3 float real = std::cos(0.3f * (float)ii); float imag = std::sin(0.3f * (float)ii); in[ii] = lv_cmake(real, imag); } // The oscillator rotates at f=0.1 float frequency = 0.1f; lv_32fc_t phase_increment = lv_cmake(std::cos(frequency), std::sin(frequency)); lv_32fc_t phase= lv_cmake(1.f, 0.0f); // start at 1 (0 rad phase) // rotate so the output is a tone at f=0.4 volk_32fc_s32fc_x2_rotator_32fc(out, in, phase_increment, &phase, N); // print results for inspection for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%%u] = %%+1.2f %+1.2fj\n", ii, lv_creal(out[ii]), lv_cimag(out[ii])); } volk_free(in); volk_free(out); ``` -------------------------------- ### VOLK Kernel Documentation Source: https://www.libvolk.org/doxygen/volk_32i_s32f_convert_32f This section provides documentation for individual VOLK kernel functions, including their purpose, dispatcher prototypes, and usage examples. ```APIDOC ## volk_32f_s32f_convert_32f ### Description Converts the samples in the inputVector from 32-bit integers into floating point values and then divides them by the input scalar. ### Method Not Applicable (This describes a function, not an API endpoint) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` // Example usage within C code: volk_32f_s32f_convert_32f(output_vector, input_vector, scalar_value, num_samples); ``` ### Response #### Success Response (200) Not Applicable (This describes a function, not an API endpoint) #### Response Example Not Applicable ``` -------------------------------- ### Example: Generating Unit Circle Points (C++) Source: https://www.libvolk.org/doxygen/volk_32f_x2_interleave_32fc This C++ example demonstrates how to generate points on the top half of the unit circle using libvolk functions. It utilizes `volk_malloc` for aligned memory allocation, `volk_32f_x2_interleave_32fc` to create complex numbers from real and imaginary components, and `volk_free` to release allocated memory. The output shows the generated complex numbers. ```cpp #include #include #include // Assuming lv_32fc_t is defined as std::complex typedef std::complex lv_32fc_t; // Forward declarations for libvolk functions extern "C" { size_t volk_get_alignment(void); void* volk_malloc(size_t size, size_t alignment); void volk_free(void *aptr); void volk_32f_x2_interleave_32fc(lv_32fc_t* complexVector, const float* iBuffer, const float* qBuffer, unsigned int num_points); } int main() { int N = 10; unsigned int alignment = volk_get_alignment(); float* imag = (float*)volk_malloc(sizeof(float)*N, alignment); float* real = (float*)volk_malloc(sizeof(float)*N, alignment); lv_32fc_t* out = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ real[ii] = 2.f * ((float)ii / (float)N) - 1.f; imag[ii] = std::sqrt(1.f - real[ii] * real[ii]); } volk_32f_x2_interleave_32fc(out, imag, real, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%%u] = %%1.2f + %%1.2fj\n", ii, std::real(out[ii]), std::imag(out[ii])); } volk_free(imag); volk_free(real); volk_free(out); return 0; } ``` -------------------------------- ### VOLK Macro for Initializing Test Cases Source: https://www.libvolk.org/doxygen/kernel__tests_8h These macros, QA, VOLK_INIT_PUPP, and VOLK_INIT_TEST, are used within the VOLK library for setting up and registering test cases. They abstract the creation of `volk_test_case_t` objects, simplifying test case initialization and management. QA macro adds a test to a list, while VOLK_INIT_PUPP and VOLK_INIT_TEST provide structured initialization for test functions with optional puppet master functions and parameters. ```c++ #include "qa_utils.h" #include #include #define QA(test) test_cases.push_back(test); #define VOLK_INIT_PUPP(func, puppet_master_func, test_params) volk_test_case_t(func##_get_func_desc(), \ (void (*)())func##_manual, \ std::string(#func), \ std::string(#puppet_master_func), \ test_params) #define VOLK_INIT_TEST(func, test_params) volk_test_case_t(func##_get_func_desc(), \ (void (*)())func##_manual, \ std::string(#func), \ test_params) ``` -------------------------------- ### volk_16ic_x2_dot_prod_16ic_neon_optvma Example Source: https://www.libvolk.org/doxygen/volk__16ic__x2__dot__prod__16ic_8h_source Example of the NEON optimized vector multiply-accumulate for 16-bit complex numbers. This function performs a dot product calculation using NEON intrinsics, suitable for ARM processors. ```c accumulator1.val[1] = vmla_s16(accumulator1.val[1], a_val.val[0], b_val.val[1]); accumulator2.val[1] = vmla_s16(accumulator2.val[1], a_val.val[1], b_val.val[0]); a_ptr += 4; b_ptr += 4; accumulator1.val[0] = vqadd_s16(accumulator1.val[0], accumulator2.val[0]); accumulator1.val[1] = vqadd_s16(accumulator1.val[1], accumulator2.val[1]); vst2_s16((int16_t*)accum_result, accumulator1); *out = accum_result[0] + accum_result[1] + accum_result[2] + accum_result[3]; ``` -------------------------------- ### Initialize Keyword Arguments Dictionary Source: https://www.libvolk.org/doxygen/namespacevolk__machine__defs Initializes an empty dictionary for keyword arguments. This is a common pattern for handling optional parameters or configuration settings. ```python volk_machine_defs.kwargs = dict() ``` -------------------------------- ### Vector Minimum Example with libvolk Memory Management (C) Source: https://www.libvolk.org/doxygen/volk_64f_x2_min_64f Demonstrates the usage of `volk_64f_x2_min_64f` along with libvolk's memory management functions (`volk_get_alignment`, `volk_malloc`, `volk_free`). It initializes two vectors with increasing and decreasing values, computes their element-wise minimum, prints the result, and then frees the allocated memory. ```c int N = 10; unsigned int alignment = volk_get_alignment(); double* increasing = (double*)volk_malloc(sizeof(double)*N, alignment); double* decreasing = (double*)volk_malloc(sizeof(double)*N, alignment); double* out = (double*)volk_malloc(sizeof(double)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = (double)ii; decreasing[ii] = 10.f - (double)ii; } volk_64f_x2_min_64f(out, increasing, decreasing, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%%u] = %%1.2g\n", ii, out[ii]); } volk_free(increasing); volk_free(decreasing); volk_free(out); ``` -------------------------------- ### Initialize VOLK CPU Detection in C/C++ Source: https://www.libvolk.org/doxygen/volk__cpu_8tmpl_8h_source Provides the function signature for `volk_cpu_init()`, which is responsible for initializing the VOLK CPU detection mechanisms. This function is crucial for VOLK to identify the host CPU's capabilities and select appropriate optimized kernels. ```c void volk_cpu_init (); ``` -------------------------------- ### Get Machine Alignment Source: https://www.libvolk.org/doxygen/volk_64u_popcnt Retrieves the machine alignment in bytes. ```APIDOC ## volk_get_alignment ### Description Gets the machine alignment in bytes. This value is typically used to ensure data is aligned correctly for optimal performance. ### Method Internal function call (not a typical REST API endpoint). ### Endpoint N/A (Internal function) ### Parameters None ### Response #### Success Response (void) - **Return Value** (size_t) - The machine alignment in bytes. ``` -------------------------------- ### Initialize Keyword Arguments Dictionary (Python) Source: https://www.libvolk.org/doxygen/namespacevolk__arch__defs Initializes an empty dictionary for keyword arguments. This is a standard practice in Python for functions that accept a variable number of keyword arguments. ```python volk_arch_defs.kwargs = dict() ``` -------------------------------- ### Example: Generate and Interleave Complex Numbers Source: https://www.libvolk.org/doxygen/volk_32f_x2_s32f_interleave_16ic This example demonstrates how to generate points around a unit circle, convert them into interleaved 16-bit complex integers using `volk_32f_x2_s32f_interleave_16ic`, and print the results. It utilizes VOLK's memory allocation functions (`volk_malloc`, `volk_free`) and alignment retrieval (`volk_get_alignment`). ```c int N = 10; unsigned int alignment = volk_get_alignment(); float* imag = (float*)volk_malloc(sizeof(float)*N, alignment); float* real = (float*)volk_malloc(sizeof(float)*N, alignment); lv_16sc_t* out = (lv_16sc_t*)volk_malloc(sizeof(lv_16sc_t)*N, alignment); for(unsigned int ii = 0; ii < N; ++ii){ real[ii] = 2.f * ((float)ii / (float)N) - 1.f; imag[ii] = std::sqrt(1.f - real[ii] * real[ii]); } // Normalize by smallest delta (0.02 in this example) float scale = 50.f; volk_32f_x2_s32f_interleave_16ic(out, imag, real, scale, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%%u] = %%i + %%ij\n", ii, std::real(out[ii]), std::imag(out[ii])); } volk_free(imag); volk_free(real); volk_free(out); ``` -------------------------------- ### Python Class: arch_class Constructor Source: https://www.libvolk.org/doxygen/classvolk__arch__defs_1_1arch__class Documentation for the `__init__` method of the `arch_class` in `volk_arch_defs.py`. This constructor initializes an instance of the class, taking flags, checks, and arbitrary keyword arguments. ```python def volk_arch_defs.arch_class.__init__(self, flags, checks, **kwargs) ``` -------------------------------- ### lv_creal Source: https://www.libvolk.org/doxygen/volk__32fc__s32fc__multiply__32fc_8h_source Macro to get the real part of a complex number. ```APIDOC ## lv_creal ### Description This macro extracts the real component of a complex number. ### Method `#define` ### Endpoint N/A (Macro definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response Returns the real part of the complex number. #### Response Example N/A ``` -------------------------------- ### VOLK Initialization Macros Source: https://www.libvolk.org/doxygen/kernel__tests_8h Macros used for initializing test cases for VOLK kernels, allowing for custom puppet masters or standard test parameters. ```APIDOC ## MACRO: VOLK_INIT_PUPP ### Description Initializes a test case with a specified function, a puppet master function, and test parameters. This is useful for advanced testing scenarios where a controlling function manages the test execution. ### Parameters - `func` (function) - The kernel function to be tested. - `puppet_master_func` (function) - The function that acts as the puppet master, controlling the test execution. - `test_params` (volk_test_params_t) - The parameters for the test. ### Example Request Body (Illustrative - Macro usage) ```c++ // Example of how the macro might be used in code: VOLK_INIT_PUPP(my_kernel, my_puppet_master, volk_test_params_t(1e-6f, 327.f, 131071, 1987, false, "")); ``` ### Value ```c++ volk_test_case_t(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), std::string(#puppet_master_func), test_params) ``` ## MACRO: VOLK_INIT_TEST ### Description Initializes a standard test case for a VOLK kernel with the specified function and test parameters. This is the basic macro for setting up tests. ### Parameters - `func` (function) - The kernel function to be tested. - `test_params` (volk_test_params_t) - The parameters for the test. ### Example Request Body (Illustrative - Macro usage) ```c++ // Example of how the macro might be used in code: VOLK_INIT_TEST(another_kernel, volk_test_params_t(1e-6f, 327.f, 131071, 1987, false, "")); ``` ### Value ```c++ volk_test_case_t(func##_get_func_desc(), (void (*)())func##_manual, std::string(#func), test_params) ``` ``` -------------------------------- ### lv_cimag Source: https://www.libvolk.org/doxygen/volk__32fc__s32fc__multiply__32fc_8h_source Macro to get the imaginary part of a complex number. ```APIDOC ## lv_cimag ### Description This macro extracts the imaginary component of a complex number. ### Method `#define` ### Endpoint N/A (Macro definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response Returns the imaginary part of the complex number. #### Response Example N/A ``` -------------------------------- ### Example: Using volk_32f_exp_32f with Memory Management Source: https://www.libvolk.org/doxygen/volk_32f_exp_32f This C++ example demonstrates how to use the volk_32f_exp_32f function to compute the exponential of a vector of floats. It includes proper memory allocation using volk_malloc with machine alignment, input data initialization, function execution, result printing, and memory deallocation using volk_free. ```c++ int N = 10; unsigned int alignment = volk_get_alignment(); float* in = (float*)volk_malloc(sizeof(float)*N, alignment); float* out = (float*)volk_malloc(sizeof(float)*N, alignment); in[0] = 0; in[1] = 0.5; in[2] = std::sqrt(2.f)/2.f; in[3] = std::sqrt(3.f)/2.f; in[4] = in[5] = 1; for(unsigned int ii = 6; ii < N; ++ii){ in[ii] = - in[N-ii-1]; } volk_32f_exp_32f(out, in, N); for(unsigned int ii = 0; ii < N; ++ii){ printf("exp(%1.3f) = %1.3f\n", in[ii], out[ii]); } volk_free(in); volk_free(out); ``` -------------------------------- ### Architecture Preference Loading Source: https://www.libvolk.org/doxygen/volk__prefs_8c Loads VOLK architecture preferences from storage. ```APIDOC ## GET /websites/libvolk_doxygen/volk_load_preferences ### Description Loads the architecture-specific preferences for VOLK. This function populates a structure with preferred kernel implementations based on the current architecture. ### Method `size_t` ### Endpoint `/websites/libvolk_doxygen/volk_load_preferences` ### Parameters #### Path Parameters None #### Query Parameters * **prefs_res** (volk_arch_pref_t **) - A pointer to a pointer that will be populated with the loaded architecture preferences. ### Request Example ```json { "prefs_res": "pointer_to_volk_arch_pref_t_structure" } ``` ### Response #### Success Response (200) - **return_value** (size_t) - The number of preferences loaded or an indicator of success/failure. - **prefs_res** (volk_arch_pref_t *) - The populated structure containing architecture preferences. #### Response Example ```json { "return_value": 10, "prefs_res": { "arch_prefs": [ { "arch_name": "SSE2", "pref": 1 } ] } } ``` ``` -------------------------------- ### C: Example VOLK Dispatcher with Tail Case Handling Source: https://www.libvolk.org/doxygen/md__home_johannes_src_volk_switch_kernels__r_e_a_d_m_e This C code demonstrates a custom kernel dispatcher for VOLK, specifically handling the 'add' operation for 32-bit floating-point vectors. It checks for pointer alignment to call optimized aligned or unaligned implementations and then processes the remaining elements in a tail case. ```c #include #ifdef LV_HAVE_DISPATCHER static inline void volk_32f_x2_add_32f_dispatcher(float* cVector, const float* aVector, const float* bVector, unsigned int num_points) { const unsigned int num_points_r = num_points%4; const unsigned int num_points_x = num_points - num_points_r; if (volk_is_aligned(VOLK_OR_PTR(cVector, VOLK_OR_PTR(aVector, bVector)))) { volk_32f_x2_add_32f_a(cVector, aVector, bVector, num_points_x); } else { volk_32f_x2_add_32f_u(cVector, aVector, bVector, num_points_x); } volk_32f_x2_add_32f_g(cVector+num_points_x, aVector+num_points_x, bVector+num_points_x, num_points_r); } #endif //LV_HAVE_DISPATCHER ``` -------------------------------- ### volk_16i_x4_quad_max_star_16i Functions Source: https://www.libvolk.org/doxygen/volk__16i__x4__quad__max__star__16i_8h This section details the different implementations of the volk_16i_x4_quad_max_star_16i kernel, optimized for SSE2, NEON, and generic architectures. ```APIDOC ## POST /kernel/volk_16i_x4_quad_max_star_16i ### Description Performs a "quad max star" operation on four input 16-bit integer arrays, storing the result in a target array. This function is available in optimized versions for SSE2 and NEON instruction sets, as well as a generic fallback. ### Method POST ### Endpoint /kernel/volk_16i_x4_quad_max_star_16i ### Parameters #### Request Body - **target** (short*) - Required - Pointer to the destination array where the result will be stored. - **src0** (short*) - Required - Pointer to the first source array. - **src1** (short*) - Required - Pointer to the second source array. - **src2** (short*) - Required - Pointer to the third source array. - **src3** (short*) - Required - Pointer to the fourth source array. - **num_points** (unsigned int) - Required - The number of elements to process in each array. - **arch** (string) - Optional - Specifies the architecture to use (e.g., "sse2", "neon", "generic"). If not provided, the library may select the best available architecture. ### Request Example ```json { "target": "0x12345678", "src0": "0xABCDEF01", "src1": "0x23456789", "src2": "0x98765432", "src3": "0x11223344", "num_points": 1024, "arch": "sse2" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` #### Error Response (400) - **error** (string) - Description of the error (e.g., "Invalid architecture specified"). ``` -------------------------------- ### Initialize VOLK CPU Kernels (C) Source: https://www.libvolk.org/doxygen/volk__cpu_8tmpl_8c Initializes the CPU-specific kernels for the Vector Optimized Library of Kernels (VOLK). This function sets up the necessary structures and configurations for CPU-based computations. It requires standard C libraries. ```c #include #include #include #include void volk_cpu_init (void) ``` -------------------------------- ### Initialize Machines List Source: https://www.libvolk.org/doxygen/namespacevolk__machine__defs Initializes an empty list to store machine definitions. This list is expected to be populated with machine objects or configurations. ```python volk_machine_defs.machines = list() ``` -------------------------------- ### Memory Management Utilities Source: https://www.libvolk.org/doxygen/volk_32f_index_min_16u Provides functions for getting machine alignment and allocating/deallocating memory with specified alignment. ```APIDOC ## Utilities: Memory Management ### `volk_get_alignment` #### Description Gets the machine alignment in bytes. #### Method GET #### Endpoint /websites/libvolk_doxygen/volk_get_alignment #### Parameters None #### Request Example ```c size_t alignment = volk_get_alignment(); ``` #### Response - **alignment** (size_t) - The machine alignment in bytes. #### Response Example ```json { "alignment": 32 } ``` ### `volk_malloc` #### Description Allocates `size` bytes of data aligned to `alignment`. #### Method POST #### Endpoint /websites/libvolk_doxygen/volk_malloc #### Parameters - **size** (size_t) - Required - The number of bytes to allocate. - **alignment** (size_t) - Required - The required alignment in bytes. #### Request Example ```c size_t alignment = volk_get_alignment(); float* data = (float*)volk_malloc(sizeof(float)*100, alignment); ``` #### Response - **pointer** (void*) - A pointer to the allocated memory. #### Response Example ```json { "pointer": "0x7ffc00001000" } ``` ### `volk_free` #### Description Frees memory previously allocated by `volk_malloc`. #### Method DELETE #### Endpoint /websites/libvolk_doxygen/volk_free #### Parameters - **aptr** (void*) - Required - A pointer to the memory to be freed. #### Request Example ```c void* ptr = volk_malloc(100, 32); // ... use ptr ... volk_free(ptr); ``` #### Response None #### Response Example ```json // No response body, operation is acknowledged by status code. ``` ``` -------------------------------- ### VOLK Main Function Source: https://www.libvolk.org/doxygen/testqa_8cc The `main` function serves as the entry point for the VOLK application, handling command-line arguments and program execution. ```APIDOC ## main() ### Description Entry point for the VOLK application. Handles command-line arguments and program initialization. ### Method N/A (This is a C++ function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (0 for success, non-zero for failure) N/A #### Response Example N/A ```