[PATCH] Clean Threads/
Richard Guenther
rguenth at tat.physik.uni-tuebingen.de
Wed Jan 7 13:01:16 UTC 2004
Hi!
This patch cleans the Threads/ files by doxygenifizing them and
using common code, if available, rather than duplicating existing stuff.
Ok?
Richard.
2004Jan07 Richard Guenther <richard.guenther at uni-tuebingen.de>
* src/Threads/IterateSchedulers/IterateScheduler.h: Doxygenifize,
only declare classes.
src/Threads/IterateSchedulers/Runnable.h: Doxygenifize, reorder
methods.
src/Threads/PoomaSmarts.h: Doxygenifize.
src/Threads/Scheduler.h: Doxygenifize, use #error, not CTAssert.
src/Threads/SmartsStubs.h: Doxygenifize, use IterateScheduler.h
and Runnable.h instead of duplicating code.
diff -Nru a/r2/src/Threads/IterateSchedulers/IterateScheduler.h b/r2/src/Threads/IterateSchedulers/IterateScheduler.h
--- a/r2/src/Threads/IterateSchedulers/IterateScheduler.h Wed Jan 7 13:47:20 2004
+++ b/r2/src/Threads/IterateSchedulers/IterateScheduler.h Wed Jan 7 13:47:20 2004
@@ -40,44 +40,28 @@
#ifndef ITERATE_SCHEDULER_H
#define ITERATE_SCHEDULER_H
-//----------------------------------------------------------------------
-// Functions:
-// template<class T> class IterateScheduler
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
-// The templated classes.
-// This is sort of like an abstract base class, since it doesn't
-// implement anything and you can't build one of these directly.
-//
-//----------------------------------------------------------------------
+/** @file
+ * @ingroup IterateSchedulers
+ * @brief
+ * Templates for the scheduler classes.
+ *
+ * This is sort of like abstract base classes, since it doesn't
+ * implement anything and you can't build one of these directly.
+ * They are implemented by specializing for a tag class like
+ * Stub or SerialAsync.
+ */
namespace Smarts {
-template<class T>
-class IterateScheduler
-{
-public:
- IterateScheduler() {};
- int generation() const {return generation_m;}
-private:
- int generation_m;
-};
template<class T>
-class Iterate
-{
-public:
- Iterate() {};
-private:
+class IterateScheduler;
+template<class T>
+class Iterate;
-};
template<class T>
-class DataObject
-{
-public:
- DataObject() {};
-private:
-};
+class DataObject;
+
} // close namespace Smarts
-#endif// ITERATE_SCHEDULER_H
+
+#endif // ITERATE_SCHEDULER_H
diff -Nru a/r2/src/Threads/IterateSchedulers/Runnable.h b/r2/src/Threads/IterateSchedulers/Runnable.h
--- a/r2/src/Threads/IterateSchedulers/Runnable.h Wed Jan 7 13:47:20 2004
+++ b/r2/src/Threads/IterateSchedulers/Runnable.h Wed Jan 7 13:47:20 2004
@@ -29,95 +29,63 @@
#ifndef _Runnable_h_
#define _Runnable_h_
+/** @file
+ * @ingroup IterateSchedulers
+ * @brief
+ * Base class for a schedulable object or function to be executed
+ * by the scheduler asynchronously.
+ */
+
#include <string.h>
namespace Smarts {
-/*------------------------------------------------------------------------
-CLASS
- Runnable
-
- Base class for a schedulable object or function to be executed
- by the scheduler asynchronously
-
-KEYWORDS
- Thread, Native_Interface, Task_Parallelism, Data_Parallelism.
-
-DESCRIPTION
- Runnable is the base class for system classes "Thread" and
- "Iterate". However, the user may define his/her own
- sub-class. Any class derived from Runnable, is an object that
- the scheduler understands and therefore is the mechanism to
- have something executed in parallel by the scheduler on behalf
- of the user.
-
-COPYRIGHT
- This program was prepared by the Regents of the University of
- California at Los Alamos National Laboratory (the University)
- under Contract No. W-7405-ENG-36 with the U.S. Department of
- Energy (DOE). The University has certain rights in the program
- pursuant to the contract and the program should not be copied
- or distributed outside your organization. All rights in the
- program are reserved by the DOE and the University. Neither
- the U.S. Government nor the University makes any warranty,
- express or implied, or assumes any liability or responsibility
- for the use of this software.
-
- Parts of this software have been authored at the University of
- Colorado -- Boulder. Neither University of Colorado nor its
- employees makes any warranty, express or implied, or assumes
- any liability or responsibility for the use of this SOFTWARE.
-
- This SOFTWARE may be modified for derivative use, but modified
- SOFTWARE should be clearly marked as such, so as not to
- confuse it with the versions available from Los Alamos
- National Laboratory.
-*/
+/**
+ * Runnable is the base class for system classes "Thread" and
+ * "Iterate". However, the user may define his/her own
+ * sub-class. Any class derived from Runnable, is an object that
+ * the scheduler understands and therefore is the mechanism to
+ * have something executed in parallel by the scheduler on behalf
+ * of the user.
+ */
class Runnable
{
- friend class Context;
public:
- ///////////////////////////
- // Set priority of this runnable relative to other runnables
- // being scheduled.
- //
- inline int
- priority() { return priority_m; };
-
- ///////////////////////////
- // Accessor function to priority.
- //
- inline void
- priority(int _priority) { priority_m = _priority; };
-
- /////////
- virtual ~Runnable(){};
-
- /////////
Runnable()
{
priority_m = 0;
}
- ///////////////////////////
- // The parameter to this constructor is the CPU id for
- // hard affinity.
- //
- Runnable(int )
+ /// The parameter to this constructor is the CPU id for
+ /// hard affinity.
+
+ Runnable(int)
{
priority_m = 0;
}
- ////////
- virtual void execute(){
- run();
- };
+ virtual ~Runnable() {}
+
+ /// Accessor function to priority.
+ inline int
+ priority() { return priority_m; }
+
+ /// Set priority of this runnable relative to other runnables
+ /// being scheduled.
+
+ inline void
+ priority(int _priority) { priority_m = _priority; }
+
+ virtual void execute()
+ {
+ run();
+ }
protected:
- virtual void run(){};
+ virtual void run() {}
private:
int priority_m;
@@ -130,5 +98,6 @@
inline void add(RunnablePtr_t);
-}
+} // namespace Smarts
+
#endif
diff -Nru a/r2/src/Threads/PoomaSmarts.h b/r2/src/Threads/PoomaSmarts.h
--- a/r2/src/Threads/PoomaSmarts.h Wed Jan 7 13:47:20 2004
+++ b/r2/src/Threads/PoomaSmarts.h Wed Jan 7 13:47:20 2004
@@ -29,25 +29,17 @@
#ifndef POOMA_THREADS_POOMA_SMARTS_H
#define POOMA_THREADS_POOMA_SMARTS_H
-//-----------------------------------------------------------------------------
-// Types:
-// Pooma::SmartsTag_t
-// Pooma::Scheduler_t
-// Pooma::DataObject_t
-// Pooma::Iterate_t
-//
-// Global Data:
-// Pooma::schedulerVersion
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Overview:
-// The POOMA wrapper around defines, includes, and typedefs for the Smarts
-// run-time evaluation system. Based on the settings of POOMA_THREADS and
-// the selected scheduler, define several typedefs and include the necessary
-// files. If we're compiling only for serial runs, use a stub version of
-// the Smarts interface instead.
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup Threads
+ * @brief
+ * The POOMA wrapper around defines, includes, and typedefs for the Smarts
+ * run-time evaluation system.
+ *
+ * Based on the settings of POOMA_THREADS and
+ * the selected scheduler, define several typedefs and include the necessary
+ * files. If we're compiling only for serial runs, use a stub version of
+ * the Smarts interface instead.
+ */
//-----------------------------------------------------------------------------
// Includes:
diff -Nru a/r2/src/Threads/Scheduler.h b/r2/src/Threads/Scheduler.h
--- a/r2/src/Threads/Scheduler.h Wed Jan 7 13:47:20 2004
+++ b/r2/src/Threads/Scheduler.h Wed Jan 7 13:47:20 2004
@@ -34,16 +34,16 @@
#ifndef POOMA_THREADS_SCHEDULER_H
#define POOMA_THREADS_SCHEDULER_H
-//////////////////////////////////////////////////////////////////////
-
-//-----------------------------------------------------------------------------
-// Overview:
-//
-// This file exist to wrap the correct includes from Smarts based on the
-// scheduler that we've selected. If we're running in serial then we include
-// the a stub file. This file defines a single typedef: SmartsTag_t, a policy
-// tag which is used to select the appropriate smarts data object etc.
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup Threads
+ * @brief
+ * Scheduler multiplexing based on configuration.
+ *
+ * This file exist to wrap the correct includes from Smarts based on the
+ * scheduler that we've selected. If we're running in serial then we include
+ * the a stub file. This file defines a single typedef: SmartsTag_t, a policy
+ * tag which is used to select the appropriate smarts data object etc.
+ */
//-----------------------------------------------------------------------------
// Includes:
@@ -82,8 +82,7 @@
# else
-# include "Utilities/PAssert.h"
-CTAssert(YOU_HAVE_NOT_SELECTED_A_SCHEDULER);
+# error "You have not selected a scheduler"
# endif
diff -Nru a/r2/src/Threads/SmartsStubs.h b/r2/src/Threads/SmartsStubs.h
--- a/r2/src/Threads/SmartsStubs.h Wed Jan 7 13:47:20 2004
+++ b/r2/src/Threads/SmartsStubs.h Wed Jan 7 13:47:20 2004
@@ -29,56 +29,21 @@
#ifndef POOMA_THREADS_SMARTSSTUBS_H
#define POOMA_THREADS_SMARTSSTUBS_H
-//-----------------------------------------------------------------------------
-// Functions:
-// SimpleSerialScheduler
-// SimpleSerialScheduler::Iterate
-// SimpleSerialScheduler::DataObject
-// template<class T> class IterateScheduler
-// IterateScheduler<Stub>
-// Iterate<Stub>
-// DataObject<Stub>
-// void concurrency(int)
-// int concurrency()
-// wait
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup IterateSchedulers
+ * @brief
+ * Stub scheduler for serial in-order evaluation.
+ */
//-----------------------------------------------------------------------------
// Includes:
//-----------------------------------------------------------------------------
-//----------------------------------------------------------------------
-// The templated classes.
-// This is sort of like an abstract base class, since it doesn't
-// implement anything and you can't build one of these directly.
-//----------------------------------------------------------------------
+#include "Threads/IterateSchedulers/IterateScheduler.h"
+#include "Threads/IterateSchedulers/Runnable.h"
namespace Smarts {
-template<class T>
-class IterateScheduler
-{
-private:
- // Private ctor means you can't build one of these.
- IterateScheduler() {}
-};
-
-template<class T>
-class Iterate
-{
-private:
- // Private ctor means you can't build one of these.
- Iterate() {}
-};
-
-template<class T>
-class DataObject
-{
-private:
- // Private ctor means you can't build one of these.
- DataObject() {}
-};
-
//----------------------------------------------------------------------
// The tag class we'll use for the template parameter.
//----------------------------------------------------------------------
@@ -93,6 +58,7 @@
template<> class IterateScheduler<Stub>;
template<> class DataObject<Stub>;
+
////////////////////////////////////////////////////////////////////////
//
// The specialization of Iterate for Stub
@@ -100,7 +66,7 @@
////////////////////////////////////////////////////////////////////////
template<>
-class Iterate<Stub>
+class Iterate<Stub> : public Runnable
{
public:
// Construct the Iterate with:
@@ -244,30 +210,9 @@
{
}
-class Runnable
-{
-public:
- // Runnable just takes affinity.
- inline Runnable(int affinity)
- : affinity_m(affinity)
- { }
-
- // The dtor is virtual because the subclasses will need to add to it.
- virtual ~Runnable() {}
- virtual void run() = 0;
-
- int affinity() { return affinity_m; }
- int hintAffinity() { return affinity_m; }
- void affinity(int) {}
- void hintAffinity(int) {}
-
-private:
- int affinity_m;
-};
-
inline void add(Runnable *runnable)
{
- runnable->run();
+ runnable->execute();
delete runnable;
}
More information about the pooma-dev
mailing list