mdcore
0.1.5
|
00001 /******************************************************************************* 00002 * This file is part of mdcore. 00003 * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk) 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published 00007 * by the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 ******************************************************************************/ 00019 00020 /* runner error codes */ 00021 #define runner_err_ok 0 00022 #define runner_err_null -1 00023 #define runner_err_malloc -2 00024 #define runner_err_space -3 00025 #define runner_err_pthread -4 00026 #define runner_err_engine -5 00027 #define runner_err_spe -6 00028 #define runner_err_mfc -7 00029 #define runner_err_unavail -8 00030 #define runner_err_fifo -9 00031 #define runner_err_verlet_overflow -10 00032 00033 00034 /* some constants */ 00035 /* Minimum number of nanoseconds to sleep if no task available. */ 00036 #define runner_minsleep 1000 00037 00039 #define runner_bitesize 3 00040 00042 #define runner_verlet_bitesize 200 00043 00046 #define runner_qlen 8 00047 00049 #define runner_dispatch_stop 0xffffffff 00050 #define runner_dispatch_lookahead 20 00051 00052 00053 /* the last error */ 00054 extern int runner_err; 00055 00056 00057 /* The fifo-queue for dispatching. */ 00058 struct runner_fifo { 00059 00060 /* Access mutex and condition signal for blocking use. */ 00061 pthread_mutex_t mutex; 00062 pthread_cond_t cond; 00063 00064 /* Counters. */ 00065 int first, last, size, count; 00066 00067 /* The FIFO data. */ 00068 int *data; 00069 00070 }; 00071 00072 00073 00074 /* the runner structure */ 00075 struct runner { 00076 00077 /* the engine with which i am associated */ 00078 struct engine *e; 00079 00080 /* this runner's id */ 00081 int id; 00082 00083 /* my thread */ 00084 pthread_t thread; 00085 00086 #ifdef CELL 00087 00088 /* the SPE context */ 00089 spe_context_ptr_t spe; 00090 pthread_t spe_thread; 00091 00092 /* the (re-)entry point */ 00093 unsigned int entry; 00094 00095 /* the initialization data */ 00096 void *data; 00097 00098 /* the compacted cell list */ 00099 struct celldata *celldata; 00100 00101 #endif 00102 00104 int err; 00105 00107 double epot; 00108 00110 struct fifo in; 00111 00112 }; 00113 00114 #ifdef CELL 00115 struct celldata { 00116 int ni; 00117 unsigned long long ai; 00118 }; 00119 #endif 00120 00121 /* associated functions */ 00122 int runner_dispatcher ( struct engine *e ); 00123 int runner_dopair ( struct runner *r , struct cell *cell_i , struct cell *cell_j , FPTYPE *shift ); 00124 int runner_dopair_unsorted ( struct runner *r , struct cell *cell_i , struct cell *cell_j , FPTYPE *shift ); 00125 int runner_dopair_verlet2 ( struct runner *r , struct cell *cell_i , struct cell *cell_j , FPTYPE *pshift , struct cellpair *cp ); 00126 int runner_dopair_verlet ( struct runner *r , struct cell *cell_i , struct cell *cell_j , FPTYPE *pshift , struct cellpair *cp ); 00127 int runner_init_SPU ( struct runner *r , struct engine *e , int id ); 00128 int runner_init ( struct runner *r , struct engine *e , int id ); 00129 int runner_run_pairs ( struct runner *r ); 00130 int runner_run_tuples ( struct runner *r ); 00131 int runner_run_verlet ( struct runner *r ); 00132 void runner_sort_ascending ( unsigned int *parts , int N ); 00133 void runner_sort_descending ( unsigned int *parts , int N ); 00134 int runner_verlet_eval ( struct runner *r , struct cell *c , FPTYPE *f_out ); 00135 int runner_verlet_fill ( struct runner *r , struct cell *cell_i , struct cell *cell_j , FPTYPE *pshift );