Skip to content

Commit 523cb1e

Browse files
committed
v2.6 +multi-threading
1 parent 2364bbf commit 523cb1e

File tree

10 files changed

+319
-240
lines changed

10 files changed

+319
-240
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
SIGNAL SERVER CHANGELOG
22

3+
2.6 - 9 June 2015
4+
Multithreading support added by Michael Ramnarine
5+
PlotPropagation() and PlotLOSMap() use four threads by default
6+
Feature can be disabled with -nothreads flag
7+
Static and global variables have been made threadsafe
8+
39
2.5 - 27 May 2015
410
Code refactored by Andrew Clayton / ac000 with header files
511
New Makefile with c / c++ multi mode compilation

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CC = gcc
44
CXX = g++
55
CFLAGS = -Wall -O3 -s -ffast-amth
66
CXXFLAGS = -Wall -O3 -s -ffast-math
7-
LIBS = -lm
7+
LIBS = -lm -lpthread
88

99
VPATH = models
1010
objects = main.o cost.o ecc33.o ericsson.o fspl.o hata.o itwom3.0.o \

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* *
2121
\****************************************************************************/
2222

23-
-- Signal Server 2.5 --
23+
-- Signal Server 2.6 --
2424
Compiled for 64 tiles at 1200 pixels/degree
2525

2626
-d Directory containing .sdf tiles
@@ -52,4 +52,6 @@
5252
-ked Knife edge diffraction (Default for ITM)
5353
-ng Normalise Path Profile graph
5454
-haf Halve 1 or 2 (optional)
55+
-nothreads Turn off threaded processing (optional)
56+
5557

common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extern double clutter;
9898
extern double dBm;
9999
extern double loss;
100100
extern double field_strength;
101-
extern double *elev;
101+
extern __thread double *elev;
102102

103103
extern char string[];
104104
extern char sdf_path[];
@@ -110,7 +110,7 @@ extern unsigned char metric;
110110
extern unsigned char dbm;
111111

112112
extern struct dem *dem;
113-
extern struct path path;
113+
extern __thread struct path path;
114114
extern struct LR LR;
115115
extern struct region region;
116116

main.cc

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
double version = 2.5;
1+
double version = 2.6;
22
/****************************************************************************\
33
* Signal Server: Server optimised SPLAT! by Alex Farrant *
44
******************************************************************************
@@ -53,11 +53,11 @@ int min_north = 90, max_north = -90, min_west = 360, max_west = -1, ippd, mpi,
5353

5454
unsigned char got_elevation_pattern, got_azimuth_pattern, metric = 0, dbm = 0;
5555

56-
double *elev;
57-
56+
__thread double *elev;
57+
__thread struct path path;
5858
struct site tx_site[2];
5959
struct dem *dem;
60-
struct path path;
60+
6161
struct LR LR;
6262
struct region region;
6363

@@ -939,14 +939,23 @@ static void free_dem(void)
939939
delete [] dem;
940940
}
941941

942-
static void free_path(void)
942+
void free_elev(void) {
943+
delete [] elev;
944+
}
945+
946+
void free_path(void)
943947
{
944948
delete [] path.lat;
945949
delete [] path.lon;
946950
delete [] path.elevation;
947951
delete [] path.distance;
948952
}
949953

954+
void alloc_elev(void)
955+
{
956+
elev = new double[ARRAYSIZE + 10];
957+
}
958+
950959
static void alloc_dem(void)
951960
{
952961
int i;
@@ -965,7 +974,7 @@ static void alloc_dem(void)
965974
}
966975
}
967976

968-
static void alloc_path(void)
977+
void alloc_path(void)
969978
{
970979
path.lat = new double[ARRAYSIZE];
971980
path.lon = new double[ARRAYSIZE];
@@ -980,6 +989,8 @@ int main(int argc, char *argv[])
980989
nortRxHin, nortRxHax, propmodel, winfiles, knifeedge = 0, ppa =
981990
0, normalise = 0, haf = 0, pmenv = 1;
982991

992+
bool use_threads = true;
993+
983994
unsigned char LRmap = 0, txsites = 0, topomap = 0, geo = 0, kml =
984995
0, area_mode = 0, max_txsites, ngs = 0;
985996

@@ -1047,6 +1058,7 @@ int main(int argc, char *argv[])
10471058
" -ked Knife edge diffraction (Default for ITM)\n");
10481059
fprintf(stdout, " -ng Normalise Path Profile graph\n");
10491060
fprintf(stdout, " -haf Halve 1 or 2 (optional)\n");
1061+
fprintf(stdout, " -nothreads Turn off threaded processing (optional)\n");
10501062

10511063
fflush(stdout);
10521064

@@ -1057,7 +1069,7 @@ int main(int argc, char *argv[])
10571069
* Now we know what mode we are running in, we can allocate various
10581070
* data structures.
10591071
*/
1060-
elev = new double[ARRAYSIZE + 10];
1072+
alloc_elev();
10611073
alloc_dem();
10621074
alloc_path();
10631075

@@ -1422,6 +1434,11 @@ int main(int argc, char *argv[])
14221434
}
14231435
}
14241436

1437+
//Disable threads
1438+
if (strcmp(argv[x], "-nothreads") == 0) {
1439+
z = x + 1;
1440+
use_threads = false;
1441+
}
14251442
}
14261443

14271444
/* ERROR DETECTION */
@@ -1639,12 +1656,12 @@ int main(int argc, char *argv[])
16391656

16401657
if (ppa == 0) {
16411658
if (propmodel == 2) {
1642-
PlotLOSMap(tx_site[0], altitudeLR, ano_filename);
1659+
PlotLOSMap(tx_site[0], altitudeLR, ano_filename, use_threads);
16431660
DoLOS(mapfile, geo, kml, ngs, tx_site, txsites);
16441661
} else {
16451662
// 90% of effort here
16461663
PlotPropagation(tx_site[0], altitudeLR, ano_filename,
1647-
propmodel, knifeedge, haf, pmenv);
1664+
propmodel, knifeedge, haf, pmenv, use_threads);
16481665

16491666
// Near field bugfix
16501667
PutSignal(tx_site[0].lat, tx_site[0].lon, hottest);
@@ -1683,7 +1700,7 @@ int main(int argc, char *argv[])
16831700
}
16841701
fflush(stdout);
16851702

1686-
delete [] elev;
1703+
free_elev();
16871704
free_dem();
16881705
free_path();
16891706

main.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ double ReadBearing(char *input);
2323
void ObstructionAnalysis(struct site xmtr, struct site rcvr, double f,
2424
FILE *outfile);
2525

26+
void free_elev(void);
27+
void free_path(void);
28+
void alloc_elev(void);
29+
void alloc_path(void);
30+
2631
#endif /* _MAIN_HH_ */

models/itwom3.0.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ double saalos(double d, prop_type & prop, propa_type & propa)
451451
double adiff(double d, prop_type & prop, propa_type & propa)
452452
{
453453
complex < double >prop_zgnd(prop.zgndreal, prop.zgndimag);
454-
static double wd1, xd1, afo, qk, aht, xht;
454+
static __thread double wd1, xd1, afo, qk, aht, xht;
455455
double a, q, pk, ds, th, wa, ar, wd, adiffv;
456456

457457
if (d == 0) {
@@ -513,7 +513,7 @@ double adiff(double d, prop_type & prop, propa_type & propa)
513513
double adiff2(double d, prop_type & prop, propa_type & propa)
514514
{
515515
complex < double >prop_zgnd(prop.zgndreal, prop.zgndimag);
516-
static double wd1, xd1, qk, aht, xht, toh, toho, roh, roho, dto, dto1,
516+
static __thread double wd1, xd1, qk, aht, xht, toh, toho, roh, roho, dto, dto1,
517517
dtro, dro, dro2, drto, dtr, dhh1, dhh2, /* dhec, */ dtof, dto1f,
518518
drof, dro2f;
519519
double a, q, pk, rd, ds, dsl, /* dfdh, */ th, wa, /* ar, wd, sf1, */
@@ -829,7 +829,7 @@ double adiff2(double d, prop_type & prop, propa_type & propa)
829829

830830
double ascat(double d, prop_type & prop, propa_type & propa)
831831
{
832-
static double ad, rr, etq, h0s;
832+
static __thread double ad, rr, etq, h0s;
833833
double h0, r1, r2, z0, ss, et, ett, th, q;
834834
double ascatv, temp;
835835

@@ -954,7 +954,7 @@ void qlrps(double fmhz, double zsys, double en0, int ipol, double eps,
954954
double alos(double d, prop_type & prop, propa_type & propa)
955955
{
956956
complex < double >prop_zgnd(prop.zgndreal, prop.zgndimag);
957-
static double wls;
957+
static __thread double wls;
958958
complex < double >r;
959959
double s, sps, q;
960960
double alosv;
@@ -1146,8 +1146,8 @@ void qlra(int kst[], int klimx, int mdvarx, prop_type & prop,
11461146
void lrprop(double d, prop_type & prop, propa_type & propa)
11471147
{
11481148
/* PaulM_lrprop used for ITM */
1149-
static bool wlos, wscat;
1150-
static double dmin, xae;
1149+
static __thread bool wlos, wscat;
1150+
static __thread double dmin, xae;
11511151
complex < double >prop_zgnd(prop.zgndreal, prop.zgndimag);
11521152
double a0, a1, a2, a3, a4, a5, a6;
11531153
double d0, d1, d2, d3, d4, d5, d6;
@@ -1337,8 +1337,8 @@ void lrprop(double d, prop_type & prop, propa_type & propa)
13371337
void lrprop2(double d, prop_type & prop, propa_type & propa)
13381338
{
13391339
/* ITWOM_lrprop2 */
1340-
static bool wlos, wscat;
1341-
static double dmin, xae;
1340+
static __thread bool wlos, wscat;
1341+
static __thread double dmin, xae;
13421342
complex < double >prop_zgnd(prop.zgndreal, prop.zgndimag);
13431343
double pd1;
13441344
double a0, a1, a2, a3, a4, a5, a6, iw;
@@ -1612,8 +1612,8 @@ double curve(double const &c1, double const &c2, double const &x1,
16121612
double avar(double zzt, double zzl, double zzc, prop_type & prop,
16131613
propv_type & propv)
16141614
{
1615-
static int kdv;
1616-
static double dexa, de, vmd, vs0, sgl, sgtm, sgtp, sgtd, tgtd,
1615+
static __thread int kdv;
1616+
static __thread double dexa, de, vmd, vs0, sgl, sgtm, sgtp, sgtd, tgtd,
16171617
gm, gp, cv1, cv2, yv1, yv2, yv3, csm1, csm2, ysm1, ysm2,
16181618
ysm3, csp1, csp2, ysp1, ysp2, ysp3, csd1, zd, cfm1, cfm2,
16191619
cfm3, cfp1, cfp2, cfp3;
@@ -1650,7 +1650,7 @@ double avar(double zzt, double zzl, double zzc, prop_type & prop,
16501650
double bfp1[7] = { 1.0, 0.93, 1.0, 0.93, 0.93, 1.0, 1.0 };
16511651
double bfp2[7] = { 0.0, 0.31, 0.0, 0.19, 0.31, 0.0, 0.0 };
16521652
double bfp3[7] = { 0.0, 2.00, 0.0, 1.79, 2.00, 0.0, 0.0 };
1653-
static bool ws, w1;
1653+
static __thread bool ws, w1;
16541654
double rt = 7.8, rl = 24.0, avarv, q, vs, zt, zl, zc;
16551655
double sgt, yr, temp1, temp2;
16561656
int temp_klim = propv.klim - 1;
@@ -1974,6 +1974,7 @@ void z1sq1(double z[], const double &x1, const double &x2, double &z0,
19741974
xa = xb - xa;
19751975
x = -0.5 * xa;
19761976
xb += x;
1977+
19771978
a = 0.5 * (z[ja + 2] + z[jb + 2]);
19781979
b = 0.5 * (z[ja + 2] - z[jb + 2]) * x;
19791980

0 commit comments

Comments
 (0)