Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #79

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Release Notes DDS 2.9.0
-----------------------
- Fixed crashes in certain multi-threading types
- Added GetDDSInfo to Exports.def (thanks to Paul Barden)
- Fixed casting problems with some compilers in ThreadMgr
- Updated documentation


Release Notes DDS 2.9.0 beta
----------------------------
Included code for a number of multi-threading systems:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DDS offers a wide range of functions, including par-score calculations.

Please refer to the [home page](http://privat.bahnhof.se/wb758135) for details.

The current version is DDS 2.9.0 beta, released in May 2018 and licensed under the Apache 2.0 license in the LICENSE FILE.
The current version is DDS 2.9.0, released in August 2018 and licensed under the Apache 2.0 license in the LICENSE FILE.

Release notes are in the ChangeLog file.

Expand Down Expand Up @@ -88,7 +88,7 @@ The DDS library interface is documented. You find the docs, including a Markdown

Bugs
====
Version 2.9.0 beta has no known bugs.
Version 2.9.0 has no known bugs.

Please report bugs to [email protected] and [email protected].

Binary file modified doc/DLL-dds_x.pdf
Binary file not shown.
1,655 changes: 831 additions & 824 deletions doc/DLL-dds_x.rtf

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ EXPORTS
SetThreading@4 = SetThreading
SetResources
SetResources@8 = SetResources
GetDDSInfo
GetDDSInfo@4 = GetDDSInfo
FreeMemory
FreeMemory@0 = FreeMemory
ErrorMessage
Expand Down
2 changes: 1 addition & 1 deletion src/Makefiles/Makefile_Visual
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# matters are CC_BOOST_INCL and CC_BOOST_LINK.
# On my systems (there are two), they are here:

BOOST32_PATH1 = \User\sheins\boost_1_66_0_x32_new
BOOST32_PATH1 = \Users\heins\Libraries\Boost\boost_1_66_0_x32_new
BOOST32_LIB1 = $(BOOST32_PATH1)\lib32-msvc-14.1

BOOST32_PATH2 = \Users\s.hein\Documents\Programs\boost_1_66_0_x32_14_1
Expand Down
17 changes: 7 additions & 10 deletions src/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,10 @@ int System::RunThreadsPPLIMPL()
(* CallbackDuplList[runCat])(* bop, uniques, crossrefs);

static atomic<int> thrIdNext = 0;
bool err = false;
bool err = false, err2 = false;

threadMgr.Reset(numThreads);

using namespace Concurrency;
Concurrency::Scheduler * sched = Concurrency::Scheduler::Create(
SchedulerPolicy(1, MaxConcurrency, numThreads));
sched->Attach();

Concurrency::parallel_for_each(uniques.begin(), uniques.end(),
[&](int &bno)
{
Expand All @@ -595,17 +590,19 @@ int System::RunThreadsPPLIMPL()
(* CallbackSingleList[runCat])(realThrId, bno);

if (! threadMgr.Release(thrId))
err = true;
err2 = true;
});

CurrentScheduler::Detach();
sched->Release();

if (err)
{
cout << "Too many threads, numThreads " << numThreads << endl;
return RETURN_THREAD_INDEX;
}
else if (err2)
{
cout << "Release failed, numThreads " << numThreads << endl;
return RETURN_THREAD_INDEX;
}

(* CallbackCopyList[runCat])(crossrefs);
#endif
Expand Down
63 changes: 37 additions & 26 deletions src/ThreadMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,37 @@ ThreadMgr::~ThreadMgr()

void ThreadMgr::Reset(const int nThreads)
{
if (nThreads > numRealThreads)
const unsigned n = static_cast<unsigned>(nThreads);
if (n > numRealThreads)
{
realThreads.resize(nThreads);
for (int t = numRealThreads; t < nThreads; t++)
realThreads.resize(n);
for (unsigned t = numRealThreads; t < n; t++)
realThreads[t] = false;
numRealThreads = nThreads;
numRealThreads = n;
}

if (nThreads > numMachineThreads)
if (n > numMachineThreads)
{
machineThreads.resize(nThreads);
for (int t = numMachineThreads; t < nThreads; t++)
machineThreads.resize(n);
for (unsigned t = numMachineThreads; t < n; t++)
machineThreads[t] = -1;
numMachineThreads = nThreads;
numMachineThreads = n;
}
}


int ThreadMgr::Occupy(const int machineId)
{
if (machineId >= numMachineThreads)
const unsigned m = static_cast<unsigned>(machineId);
if (m >= numMachineThreads)
{
numMachineThreads = machineId + 1;
numMachineThreads = m + 1;
machineThreads.resize(numMachineThreads);
for (int t = machineId; t < numMachineThreads; t++)
for (unsigned t = m; t < numMachineThreads; t++)
machineThreads[t] = -1;
}

if (machineThreads[machineId] != -1)
if (machineThreads[m] != -1)
{
// Error: Already in use.
return -1;
Expand All @@ -75,13 +77,14 @@ int ThreadMgr::Occupy(const int machineId)
do
{
mtx.lock();
for (int t = 0; t < numRealThreads; t++)
for (unsigned t = 0; t < numRealThreads; t++)
{
if (realThreads[t] == false)
{
const int ti = static_cast<int>(t);
realThreads[t] = true;
machineThreads[machineId] = t;
res = t;
machineThreads[m] = ti;
res = ti;
break;
}
}
Expand All @@ -102,24 +105,32 @@ int ThreadMgr::Occupy(const int machineId)

bool ThreadMgr::Release(const int machineId)
{
const int r = machineThreads[machineId];
mtx.lock();

bool ret;
const unsigned m = static_cast<unsigned>(machineId);
const int r = machineThreads[m];
const unsigned ru = static_cast<unsigned>(r);

if (r == -1)
{
// Error: Not in use.
return false;
ret = false;
}

if (! realThreads[r])
else if (! realThreads[ru])
{
// Error: Refers to a real thread that is not in use.
return false;
ret = false;
}
else
{
realThreads[ru] = false;
machineThreads[m] = -1;
ret = true;
}

mtx.lock();
realThreads[r] = false;
machineThreads[machineId] = -1;
mtx.unlock();
return true;
return ret;
}


Expand All @@ -133,15 +144,15 @@ void ThreadMgr::Print(

fo << tag <<
": Real threads occupied (out of " << numRealThreads << "):\n";
for (int t = 0; t < numRealThreads; t++)
for (unsigned t = 0; t < numRealThreads; t++)
{
if (realThreads[t])
fo << t << endl;
}
fo << endl;

fo << "Machine threads overview:\n";
for (int t = 0; t < numMachineThreads; t++)
for (unsigned t = 0; t < numMachineThreads; t++)
{
if (machineThreads[t] != -1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ThreadMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ThreadMgr

vector<bool> realThreads;
vector<int> machineThreads;
int numRealThreads;
int numMachineThreads;
unsigned numRealThreads;
unsigned numMachineThreads;

public:

Expand Down