diff --git a/aegilib/test/omp_pipeline.cpp b/aegilib/test/omp_pipeline.cpp new file mode 100644 index 000000000..8c94de47c --- /dev/null +++ b/aegilib/test/omp_pipeline.cpp @@ -0,0 +1,55 @@ +#include +#include + +double wasteTime(double in) +{ + double accum = in; + for (size_t i=0;i<5000000;i++) { + accum = accum + accum/2.0 - accum/3.0; + } + return accum; +} + +int main() +{ + using namespace std; + cout << "OpenMP test:\n"; + bool run = true; + int n = 0; + omp_set_num_threads(8); + #pragma omp parallel shared(run,n) + { + while (run) { + int myTask; + double lol = 0.0; + + #pragma omp critical (secA) + { + myTask = n; + n++; + if (myTask >= 50) run = false; + if (run) { + cout << "Thread #" << omp_get_thread_num() << " on task " << myTask << "/1.\n"; + lol -= wasteTime(myTask * 1.0); + cout << "Thread #" << omp_get_thread_num() << " got " << lol << " on task " << myTask << "/1. Task done.\n"; + } + } + + if (run) { + #pragma omp critical (secB) + { + cout << "Thread #" << omp_get_thread_num() << " on task " << myTask << "/2.\n"; + lol += wasteTime(myTask * 2.0); + cout << "Thread #" << omp_get_thread_num() << " got " << lol << " on task " << myTask << "/2. Task done.\n"; + } + + #pragma omp critical (secC) + { + cout << "Thread #" << omp_get_thread_num() << " on task " << myTask << "/3.\n"; + lol -= wasteTime(myTask * 3.0); + cout << "Thread #" << omp_get_thread_num() << " finished task " << myTask << " with the useless result of " << lol << "\n"; + } + } + } + } +} diff --git a/aegilib/test/src/main.cpp b/aegilib/test/src/main.cpp index 8a200fd49..92b191890 100644 --- a/aegilib/test/src/main.cpp +++ b/aegilib/test/src/main.cpp @@ -40,8 +40,8 @@ #include "text_file_reader.h" #include "text_file_writer.h" - -int main() { +int main() +{ using namespace std; using namespace Gorgonsub; @@ -60,7 +60,7 @@ int main() { // Load subtitles cout << "Loading file... "; timer.Start(); - control.LoadFile(L"subs_in.ass",L"UTF-16LE"); + control.LoadFile(L"subs_in.ass",L"UTF-8"); timer.Pause(); cout << "Done in " << timer.Time() << " ms.\n"; //system("pause"); diff --git a/aegilib/test/test.vcproj b/aegilib/test/test.vcproj index c87a874fc..a8c387884 100644 --- a/aegilib/test/test.vcproj +++ b/aegilib/test/test.vcproj @@ -120,6 +120,7 @@ AdditionalIncludeDirectories="../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" RuntimeLibrary="2" + OpenMP="false" UsePrecompiledHeader="0" WarningLevel="4" Detect64BitPortabilityProblems="true"