Click here to Skip to main content
16,017,788 members
Articles / High Performance Computing
Tip/Trick

HPC Template Library, A Supplement to the STL

Rate me:
Please Sign up or sign in to vote.
4.88/5 (11 votes)
15 Dec 2017MIT3 min read 39.1K   1.3K   39   5
The HPC Template Library is a supplement to the Standard Template Library providing threadsafe containers.

Download source

Author: Anthony Daniels

Introduction

This package is intended to provide the user with threadsafe containers and classes for applications in High Performance Computing (HPC) where parallel programming is commonplace. Today’s multi-core computers bring that parallelism into the realm of everyday use. It is important to provide thread safe containers and classes in this environment. The HPC Template Library (HTL) aims to replace certain portions of the STL. It is a merger and rewrite of classes from the STL, QT, Boost, and SigSlots libraries. All of the containers are now threadsafe implementing mutexes around critical operations. It is designed as a dynamic linked library for the user to include directly in their projects. It is written for the Windows platform, although the user could adapt it for use in Linux / Unix by changing only the HtlThread and HtlTime sub packages. The code is designed to be easy to read and well documented. The HTL has 14 sub packages to parcel functionality of different classes. The license for the Library is LGPL. A CSharp Version of this library is posted on this site.

HTL Packages Overview

The HTL has 14 sub packages to parcel functionality of different classes. The packages are as follows (listed in alphabetical order). As can be seen, there are a few outlying classes that need to be added, but HTL is mostly operational. The development of unit test code for the library has also commenced and is in the code package. Testing will continue.

Package Description Operational Status
HtlArchive: Contains all of the classes necessary for serialization and deserialization of objects. It contains a generic archive tree / node system and three different serializer packages (XML, XDL, JSON, Binary).

Archive Model (100%)

XML (100%)

XDL(100%)

JSON (100%)

Binary(0%) to be added

HtlAtomic: Contains a template class that allows for turning any object into an atomic object (threadsafe) via its operators.

(0 %) to be added

HtlBase: Contains the base classes for making objects serializable using the HTL system. It also has a base object that is signal slot capable using the HTL sig slots system. – (fully operational)

(100%)

HtlContainer: Contains all of the container classes of the HTL (Htl1DVector, Htl1DList, Htl2DArray, Htl3DMatrix, HtlListMap, HtlMap, etc.). All containers in this set are serializable in the HTL system. – (fully operational)

(100%)

HtlGlobal: Contains globally used enumerated types, structs, etc. – (fully operational)

(100%)

HtlGUID: Contains the three Global Unique Identifiers (GUID); 64bit, 128bit, and 256bit. – (fully operational)

(100%)

HtlMacro: Contains the set of Macros that are allowed in the HTL. HTL makes minimal use of macros because in general macros are a bad programming practice.

(100%)

HtlMath: Contains the basic math functions that supplement the STL <math.h> library.

(100%)

HtlRandNumGen: Contains a system for random number generators and random distribution generators.

(100%)

HtlSignalSlot: This is a signals and slots library that is based on the sigslots library. Some changes to the library have been made although.

(100%)

HtlString: Contains the string class that replaces the std::string. They are interoperable, meaning you can go directly between HtlString and std::string.

(100%)

HtlTest: Contains the HTL unit testing system. This is a test name based unit test system similar to boost, but no macros were used in it.

(100%)

HtlThread: Contains all thread related classes including mutexes, semaphores, threads, etc.

(100%)

HtlTime: Contains elapsed time timers and countdown timers.

(50%) countdown timer needs to be added

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questiontry / catch(...) return -1 Pin
Paulo Zemek23-Aug-17 13:04
Paulo Zemek23-Aug-17 13:04 
I saw this in the code:
C++
//test try and access the element, if bad pointer quit out gracefully
try{
  std::string strTemp = ptrElement->Get_strName();
}catch(...){
  //BAD POINTER RETURN ERROR
  return -1;
}

This is the kind of code I never expect to see in production. If invalid pointers are coming in, then the caller should be fixed. You shouldn't simply fail this action with no info on why it really failed. Worse than that, is that depending on the invalid pointer, you will not have an exception, so this code is only hiding a source of problem instead of fixing anything.

Edit:
Also, I saw this:
C++
if(ptrElement)
{
  m_ptrElement = ptrElement;
}else{
  m_ptrElement = NULL;
};

Even if this code works, I see two issues: Excessive use of ;
The if is completely unnecessary. If the value is non-null, you set m_ptrElement to the value. If value is null, then you set m_ptrElement to null. So, why not set it to m_ptrElement all the time, as you want to set it to NULL when ptrElement is NULL ?

Maybe if this was Python were something different than a NULL pointer could be falsy, the test would be OK, but in C/C++ this is not going to happen.
AnswerRe: try / catch(...) return -1 Pin
trident9925-Aug-17 5:54
trident9925-Aug-17 5:54 
GeneralRe: try / catch(...) return -1 Pin
trident999-Oct-17 7:23
trident999-Oct-17 7:23 
GeneralMy vote of 5 Pin
Juan David Barreto16-Feb-17 9:54
Juan David Barreto16-Feb-17 9:54 
GeneralMy vote of 5 Pin
Manikandan1012-Jul-14 2:58
professionalManikandan1012-Jul-14 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.