1 // =============================================================================
2 // === GPUQREngine/Include/GPUQREngine_LLBundle.hpp ============================
3 // =============================================================================
4 //
5 // LLBundle is a principal class in the GPUQREngine.
6 //
7 // This class is responsible for maintaining the CPU's view of state information
8 // during the factorization process.
9 //
10 // LLBundles are manipulated by its hosting BucketList and are:
11 //   1) Advanced
12 //   2) Created
13 //   3) Grown       (in the context of pipelining)
14 //   4) Operated on (participating in Apply, Factorize, or ApplyFactorize tasks)
15 //
16 // =============================================================================
17 
18 #ifndef GPUQRENGINE_LLBUNDLE_HPP
19 #define GPUQRENGINE_LLBUNDLE_HPP
20 
21 #include "GPUQREngine_Common.hpp"
22 #include "GPUQREngine_TaskDescriptor.hpp"
23 
24 struct TaskDescriptor;
25 class BucketList;
26 
27 class LLBundle
28 {
29 public:
30     BucketList *Buckets; // A back pointer to the hosting BucketList
31 
32     Int NativeBucket;   // The column bucket the bundle belongs "is native" to
33 
34     Int Shadow;         // A memento for the factorized First tile.
35                         // The CPU needs to know
36 
37     Int First;          // The tile with the smallest rowtile index.
38                         // For factorize tasks, this tile is made upper
39                         // triangular.
40 
41     Int Last;           // The index of the last filled slot in the bundle.
42 
43     Int Delta;          // The index of where the Delta starts
44                         // Delta is used in pipelining when we attach a
45                         // factorize task to a finishing apply.
46 
47     Int SecondMin;      // The index of where First's replacement is
48 
49     Int Max;            // The index of the largest element (by rowtile)
50 
51     Int PanelSize;
52     Int ApplyCount; // # tiles participating in an APPLY, including the Shadow.
53     Int Count;      // # tiles in the Bundle (Slots+Delta), but not the Shadow.
54 
55     double *VT[2];  // Pointers to VT tiles.
56                     // When performing a pipelined task (ApplyFactorize),
57                     // memory must be reserved for two separate VT tiles:
58                     //   1) For the HH vectors involved in the Apply
59                     //   2) For the HH vectors resulting from the factorization
60 
IsFull(void)61     bool IsFull
62     (
63         void
64     )
65     {
66         return (Count == PanelSize);
67     }
68 
69     TaskType CurrentTask;
70 
operator new(long unsigned int,LLBundle * p)71     void *operator new(long unsigned int, LLBundle* p){ return p; }
72     LLBundle(BucketList *buckets, Int panelSize, Int nativeBucket);
73 
74     // empty LLBundle constructor (currently used, kept for possible future use
75     // LLBundle();
76 
77     // LLBundle destructor:
78     ~LLBundle();
79 
80     #ifdef GPUQRENGINE_PIPELINING
81     void AddTileToDelta(Int rowTile);
82     #endif
83 
84     void AddTileToSlots(Int rowTile);
85 
86     // Advance: returns T/F if the bundle is still around after being advanced.
87     bool Advance();
88 
89     void PipelinedRearrange();
90     void UpdateSecondMinIndex();
91     void UpdateMax();
92 
93     void gpuPack(TaskDescriptor *cpuTask);
94 };
95 
96 #endif
97