Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
local_farm.h
1 /*
2  * local_gpu_farm.cuh
3  *
4  *
5  * Author:
6  *
7  * -------------------------------------------------------------------------------
8  *
9  * The MIT License
10  *
11  * Copyright 2014 Steffen Ernsting <s.ernsting@uni-muenster.de>,
12  * Herbert Kuchen <kuchen@uni-muenster.de.
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a copy
15  * of this software and associated documentation files (the "Software"), to deal
16  * in the Software without restriction, including without limitation the rights
17  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18  * copies of the Software, and to permit persons to whom the Software is
19  * furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included in
22  * all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30  * THE SOFTWARE.
31  *
32  */
33 
34 #pragma once
35 
36 #include <iostream>
37 #include <cstdlib>
38 #include <omp.h>
39 #include <utility>
40 #include <atomic>
41 
42 #include "ccdeque.h"
43 #include "process.h"
44 #ifdef __CUDACC__
45 #include "farm_kernel.cuh"
46 #endif
47 
48 namespace msl {
49 
50 namespace detail {
51 
52 template <class I, class O, class F>
53 class LocalFarm : public Process
54 {
55 public:
56  LocalFarm(F* _worker, bool cc_mode, int worker_num);
57 
58  ~LocalFarm();
59 
60  void start();
61 
62  void show() const;
63 
64 protected:
65 
66 private:
67 // Atomic<I, O, F>* worker;
68  F* worker;
69  CcDeque<std::vector<I>*> wp_in;
70  CcDeque<std::vector<O>*> wp_out;
71  int nstreams, myEntrance, nGpuTasks, nCpuTasks;
72  bool concurrent_mode;
73  std::atomic<bool> finished_in, finished_work_cpu, finished_work_gpu;
74  int sum_cpu, sum_gpu, worker_num;
75 
76  void recvInput();
77 
78  void farmCpu();
79 
80  void farmGpu();
81 };
82 
83 }
84 }
85 
86 #include "../../src/local_farm.cpp"
Definition: ccdeque.h:44
Definition: process.h:44
Definition: local_farm.h:53