Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
MultiGPUMapper.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2012-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Mike Hallock
38 */
39
40#ifndef __MULTIGPUMAPPER__
41#define __MULTIGPUMAPPER__
42
43#define POSDIM(_p, _d) ((_p).x + (_p).y * (_d).x + (_p).z * (_d).x * (_d).y)
44#define DIMSIZE(_d) ((_d).x*(_d).y*(_d).z)
45
46#include <pthread.h>
47#include "SegmentDescriptor.h"
48
50{
51 protected:
56 size_t cellsize;
57 pthread_key_t affinity;
58 int apron;
60 float *lb_weights;
61 int *lb_cost;
64
65 virtual void initialize()=0;
66 bool enable_peer_access(int src, int dst);
67 void build_descriptor(int gpu, dim3 ldim, int3 goffset, dim3 active, dim3 loffset);
69
70 public:
71 MultiGPUMapper(dim3 ldim, size_t cellsize, int apron, int overlap, int num_gpus, int* devices, int pages);
72 virtual ~MultiGPUMapper();
73
75 bool use(int gpu);
76
78
79 int get_apron();
80
81 void set_affinity(int);
83
87
88 void record_execution_cost(int, int);
89 bool rebalance();
91
92 // virtual interface
93 virtual dim3 get_global_dim(int gpu)=0;
94 virtual dim3 get_local_dim(int gpu)=0;
95 virtual int3 get_global_offset(int gpu)=0;
96 virtual size_t get_local_size(int gpu)=0;
97 virtual size_t get_authority_size(int gpu)=0;
98 virtual ssize_t get_global_input_offset(int gpu)=0;
99 virtual size_t get_global_output_offset(int gpu)=0;
100 virtual size_t get_authority_offset(int gpu)=0;
101 virtual void stage_in(int gpu, void *dptr, void *hptr)=0;
102 virtual void stage_in_sites(int gpu, void *dptr, void *hptr)=0;
103 virtual void stage_out(int gpu, void *hptr, void *dptr)=0;
104 virtual void publish_state(int gpu, int timestamp,
105 cudaStream_t top, cudaStream_t bot,
106 void *dptr = NULL)=0;
107 virtual void refresh(int gpu, void *dptr, int timestamp)=0;
108
109 virtual void schedule_send(int gpu, void *dptr, int timestamp, int neighbor, cudaStream_t stream)=0;
110 virtual void schedule_recv(int gpu, void *dptr, int timestamp, int neighbor, cudaStream_t stream)=0;
111
112 virtual int map_index_to_gpu(size_t index)=0;
113
114 virtual void initialize_gpu(int gpu);
115
116 virtual bool determine_load_balance()=0;
117
118};
119
120#define check_error() ({ cudaError_t err=cudaGetLastError(); if(err!=cudaSuccess) { printf("Cuda error %s:%d: %s\n", __FILE__, __LINE__,cudaGetErrorString(err)); exit(1); } })
121
122
123#endif
struct segmentDescriptor SegmentDescriptor_s
Definition SegmentDescriptor.h:57
virtual size_t get_authority_offset(int gpu)=0
virtual void initialize_gpu(int gpu)
SegmentDescriptor_s ** descriptor
Definition MultiGPUMapper.h:59
int apron
Definition MultiGPUMapper.h:58
float * lb_weights
Definition MultiGPUMapper.h:60
MultiGPUMapper(dim3 ldim, size_t cellsize, int apron, int overlap, int num_gpus, int *devices, int pages)
virtual void schedule_send(int gpu, void *dptr, int timestamp, int neighbor, cudaStream_t stream)=0
size_t cellsize
Definition MultiGPUMapper.h:56
virtual void stage_out(int gpu, void *hptr, void *dptr)=0
int overlap
Definition MultiGPUMapper.h:55
virtual bool determine_load_balance()=0
dim3 lattice_dim
Definition MultiGPUMapper.h:54
virtual dim3 get_local_dim(int gpu)=0
void set_affinity(int)
virtual void publish_state(int gpu, int timestamp, cudaStream_t top, cudaStream_t bot, void *dptr=NULL)=0
int num_gpus
Definition MultiGPUMapper.h:52
int * lb_cost
Definition MultiGPUMapper.h:61
virtual void stage_in_sites(int gpu, void *dptr, void *hptr)=0
SegmentDescriptor_s * getSegmentDescriptor(int gpu)
pthread_key_t affinity
Definition MultiGPUMapper.h:57
size_t get_global_size()
virtual int map_index_to_gpu(size_t index)=0
virtual int3 get_global_offset(int gpu)=0
virtual void initialize()=0
virtual size_t get_authority_size(int gpu)=0
virtual void stage_in(int gpu, void *dptr, void *hptr)=0
virtual ssize_t get_global_input_offset(int gpu)=0
int * device_id
Definition MultiGPUMapper.h:53
virtual size_t get_global_output_offset(int gpu)=0
void compute_balances()
size_t * device_memory
Definition MultiGPUMapper.h:62
void build_descriptor(int gpu, dim3 ldim, int3 goffset, dim3 active, dim3 loffset)
int pagecount
Definition MultiGPUMapper.h:63
virtual void refresh(int gpu, void *dptr, int timestamp)=0
bool use(int gpu)
bool enable_peer_access(int src, int dst)
virtual void schedule_recv(int gpu, void *dptr, int timestamp, int neighbor, cudaStream_t stream)=0
virtual size_t get_local_size(int gpu)=0
bool numa_bind_thread(int)
virtual ~MultiGPUMapper()
virtual dim3 get_global_dim(int gpu)=0
dim3 get_lattice_dim()
void record_execution_cost(int, int)