![]() |
Sorting Network Search
Backtracking for Small Sorting Networks
|
Main. More...
#include <iostream>
#include <fstream>
#include <stdexcept>
#include "Nearsort2.h"
#include "ThreadManager.h"
#include "Task.h"
#include "Timer.h"
#include "TernaryGrayCode.h"
Go to the source code of this file.
Functions | |
size_t | getn (const std::string &strBanner) |
Get size_t from input. More... | |
bool | CheckParams (const size_t n, const size_t d) |
Check that depth is reasonable for width. More... | |
void | ReadParams (size_t &n, size_t &d) |
Read parameters for search. More... | |
void | ReadParams (bool &bNearsort2, const size_t d) |
Read optimization settings. More... | |
void | SaveSummary (const std::string s) |
Save summary string. More... | |
void | Search (CThreadManager *p, const size_t nDepth, const bool bNearsort2) |
Multi-threaded search. More... | |
int | main () |
Main. More... | |
Prompt the user for width (number of inputs) and depth, then spawn a multi-threaded backtracking search for sorting networks of the given width and depth. The user is also prompted to choose whether the new search hauristic nearsort2 is to the used.
Definition in file Main.cpp.
bool CheckParams | ( | const size_t | n, |
const size_t | d | ||
) |
Check that depth is reasonable for width, that is, either equal to or one less than the smallest known depth. An error message is printed to stdout if it is not. This function assumes that \(n \leq 12\).
n | Width. |
d | Depth. |
size_t getn | ( | const std::string & | strBanner | ) |
int main | ( | ) |
void ReadParams | ( | bool & | bNearsort2, |
const size_t | d | ||
) |
void ReadParams | ( | size_t & | n, |
size_t & | d | ||
) |
void SaveSummary | ( | const std::string | s | ) |
void Search | ( | CThreadManager * | p, |
const size_t | nDepth, | ||
const bool | bNearsort2 | ||
) |
Conduct multi-threaded sorting network search. First search for all level 2 candidates, then pass each one as a task to the thread manager. Get the thread manager to spawn the search threads, wait until they terminate, then process the results.
p | Pointer to thread manager. |
nDepth | Sorting network depth. |
bNearsort2 | true to use nearsort2 heuristic (if appropriate). |