# gd32fun **Repository Path**: pomimi/gd32fun ## Basic Information - **Project Name**: gd32fun - **Description**: gd32+FreeRTOS+MQTT+u8g2 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-11-16 - **Last Updated**: 2025-11-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # C++ Implementation of the Parallelized Sieve of Eratosthenes This project provides a C++ implementation of the **parallelized Sieve of Eratosthenes** algorithm for efficiently finding all prime numbers within a given range. The parallelization is achieved using **OpenMP**, enabling the program to leverage multi-core processors and significantly improve performance for large input sizes. ## Features - Efficiently computes all prime numbers up to a specified maximum value (`N`). - Utilizes **OpenMP** for parallel processing. - Supports large values of `N` while maintaining good performance. - Easy-to-use command line interface. ## Requirements - C++11 or later - OpenMP support - A compiler compatible with OpenMP (e.g., GCC, Clang, MSVC with appropriate flags) ## Usage To use this program, simply run it from the command line and provide the upper bound `N` for the sieve: ```bash ./parallel_eratosthenes N ``` Example: ```bash ./parallel_eratosthenes 100 ``` This will print all prime numbers less than or equal to 100. ## Compilation To compile the program, use the following command (assuming GCC or compatible compiler): ```bash g++ -fopenmp -O3 README.md.cpp -o parallel_eratosthenes ``` The `-fopenmp` flag enables OpenMP support, and `-O3` enables high-level optimizations for better performance. ## Algorithm Overview The **Sieve of Eratosthenes** works by iteratively marking the multiples of each prime number starting from 2. The parallelized version implemented here divides the range into segments and processes them concurrently using multiple threads. ## Performance Considerations - The program scales well with larger values of `N` due to its parallelized implementation. - The number of threads used can be controlled by setting the environment variable `OMP_NUM_THREADS` or by using `omp_set_num_threads()` within the code. ## License This project is licensed under the MIT License - see the [LICENSE](#) file for details. ## Contributions Contributions are welcome! Please feel free to submit a pull request or open an issue for any improvements or bug fixes. ## Acknowledgments - The Sieve of Eratosthenes algorithm, one of the oldest known efficient methods for finding prime numbers. - OpenMP for enabling easy parallelization across platforms.