Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit a8f331d

Browse files
fouriauxpramodk
authored andcommitted
Centralize global variables definitions (#79)
- clean up extern declarations and multiple definitions - remove test in source of optargs as it is already tested in ctests
1 parent baef043 commit a8f331d

File tree

13 files changed

+21
-60
lines changed

13 files changed

+21
-60
lines changed

coreneuron/nrniv/netcvode.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ THE POSSIBILITY OF SUCH DAMAGE.
3636
#include "coreneuron/nrniv/netcvode.h"
3737
#include "coreneuron/nrniv/ivocvect.h"
3838
#include "coreneuron/nrniv/nrniv_decl.h"
39+
#include "coreneuron/nrnoc/nrnoc_decl.h"
3940
#include "coreneuron/nrniv/output_spikes.h"
4041
#include "coreneuron/nrniv/nrn_assert.h"
4142
#include "coreneuron/nrniv/nrn_acc_manager.h"
4243
#include "coreneuron/nrniv/multisend.h"
44+
#include "coreneuron/nrnoc/membfunc.h"
4345
#ifdef _OPENACC
4446
#include <openacc.h>
4547
#endif
@@ -63,10 +65,8 @@ void mk_netcvode() {
6365
}
6466
}
6567

66-
extern void nrn_outputevent(unsigned char, double);
6768
extern "C" {
68-
extern pnt_receive_t* pnt_receive;
69-
extern pnt_receive_t* pnt_receive_init;
69+
//TODO following declarations dont appears in any include files
7070
extern short* nrn_artcell_qindex_;
7171
extern bool nrn_use_localgid_;
7272
extern void nrn2ncs_outputevent(int netcon_output_index, double firetime);
@@ -76,8 +76,6 @@ void net_move(void**, Point_process*, double);
7676
void net_sem_from_gpu(int sendtype, int i_vdata, int, int ith, int ipnt, double, double);
7777
void artcell_net_send(void**, int, Point_process*, double, double);
7878
void artcell_net_move(void**, Point_process*, double);
79-
extern void nrn_fixed_step_minimal();
80-
extern void nrn_fixed_step_group_minimal(int);
8179

8280
#ifdef DEBUG
8381
// temporary

coreneuron/nrniv/netpar.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3434
#include "coreneuron/nrnoc/multicore.h"
3535
#include "coreneuron/nrnmpi/nrnmpi.h"
3636
#include "coreneuron/nrnoc/nrnoc_decl.h"
37-
37+
#include "coreneuron/nrnmpi/nrnmpidec.h"
3838
class PreSyn;
3939
class InputPreSyn;
4040

@@ -49,8 +49,6 @@ static double t_exchange_;
4949
static double dt1_; // 1/dt
5050

5151
extern "C" {
52-
extern double t, dt;
53-
extern void nrn_fake_fire(int gid, double firetime, int fake_out);
5452
void nrn_spike_exchange_init();
5553
}
5654

@@ -677,7 +675,7 @@ static void mk_localgid_rep() {
677675
// set the third arg to 1 and set the output cell thresholds very
678676
// high so that they do not themselves generate spikes.
679677
// Can only be called by thread 0 because of the ps->send.
680-
void nrn_fake_fire(int gid, double spiketime, int fake_out) {
678+
extern "C" void nrn_fake_fire(int gid, double spiketime, int fake_out) {
681679
std::map<int, InputPreSyn*>::iterator gid2in_it;
682680
gid2in_it = gid2in.find(gid);
683681
if (gid2in_it != gid2in.end()) {

coreneuron/nrniv/nrn_filehandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
2929
#include <iostream>
3030
#include "coreneuron/nrniv/nrn_filehandler.h"
3131
#include "coreneuron/nrnconf.h"
32-
extern "C" void check_bbcore_write_version(const char*);
3332

3433
FileHandler::FileHandler(const char* filename, bool reorder) {
3534
this->open(filename, reorder);

coreneuron/nrniv/nrn_stats.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
4141
#include "coreneuron/nrnoc/multicore.h"
4242
#include "coreneuron/nrniv/netcvode.h"
4343
#include "coreneuron/nrniv/partrans.h"
44-
45-
extern std::vector<int> spikevec_gid;
44+
#include "coreneuron/nrniv/output_spikes.h"
4645
extern NetCvode* net_cvode_instance;
4746

4847
const int NUM_STATS = 12;

coreneuron/nrniv/nrnoptarg.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -368,26 +368,3 @@ static void graceful_exit(int err) {
368368
#endif
369369
exit(nrnmpi_myid == 0 ? err : 0);
370370
}
371-
372-
#if defined(nrnoptargtest)
373-
// for testing, compile with: g++ -g -I../.. nrnoptarg.cpp
374-
375-
int nrnmpi_myid;
376-
377-
int main(int argc, const char* argv[]) {
378-
nrnopt_parse(argc, argv);
379-
380-
printf("prcellgid = %d\n", nrnopt_get_int("--prcellgid"));
381-
printf("outpath = %s\n", nrnopt_get_str("--outpath").c_str());
382-
383-
printf("before modify dt = %g\n", nrnopt_get_dbl("--dt"));
384-
nrnopt_modify_dbl("--dt", 18.1);
385-
printf("after modify to 18.1, dt = %g\n", nrnopt_get_dbl("--dt"));
386-
387-
nrnopt_show();
388-
389-
nrnopt_delete();
390-
return 0;
391-
}
392-
393-
#endif // test

coreneuron/nrniv/profiler_interface.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <stdio.h>
2-
2+
#include "coreneuron/nrnmpi/nrnmpi.h"
33
#ifdef CUDA_PROFILING
44
#include "coreneuron/nrniv/cuda_profile.h"
55
#endif
@@ -19,7 +19,6 @@ static int cray_acc_debug_orig = 0;
1919
static int cray_acc_debug_zero = 0;
2020
#endif
2121

22-
extern int nrnmpi_myid;
2322

2423
void start_profile() {
2524
if (nrnmpi_myid == 0)

coreneuron/nrnoc/eion.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ THE POSSIBILITY OF SUCH DAMAGE.
3131

3232
#include "coreneuron/coreneuron.h"
3333
#include "coreneuron/nrnoc/nrnoc_decl.h"
34-
34+
#include "coreneuron/nrnmpi/nrnmpi.h"
35+
#include "coreneuron/nrnoc/membfunc.h"
3536
#if !defined(LAYOUT)
3637
/* 1 means AoS, >1 means AoSoA, <= 0 means SOA */
3738
#define LAYOUT 1
@@ -67,7 +68,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
6768
#define _PRAGMA_FOR_SEC_ORDER_CUR_ACC_LOOP_ _Pragma("")
6869
#endif
6970

70-
extern void hoc_register_prop_size(int, int, int);
7171

7272
#define nparm 5
7373
static char* mechanism[] = {/*just a template*/
@@ -205,7 +205,6 @@ void nrn_wrote_conc(int type,
205205
int _cntml_padded) {
206206
#ifndef _OPENACC
207207
static int flag = 1;
208-
extern int nrnmpi_myid;
209208
if (flag && nrnmpi_myid == 0) {
210209
/** need to check this as this kernel was failing */
211210
printf("\n WARNING: nrn_nrn_wrote_conc support on GPU need to validate!\n");

coreneuron/nrnoc/fadvance_core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ THE POSSIBILITY OF SUCH DAMAGE.
3232
#include "coreneuron/nrnoc/nrnoc_decl.h"
3333
#include "coreneuron/nrniv/nrn_acc_manager.h"
3434
#include "coreneuron/coreneuron.h"
35-
35+
extern nrn_flush_reports(double t); // TODO remove when this file goes as cpp
3636
static void* nrn_fixed_step_thread(NrnThread*);
3737
static void* nrn_fixed_step_group_thread(NrnThread*);
38-
extern void nrn_flush_reports(double);
3938

4039
void dt2thread(double adt) { /* copied from nrnoc/fadvance.c */
4140
if (adt != nrn_threads[0]._dt) {
@@ -203,7 +202,6 @@ void nrn_ba(NrnThread* nt, int bat) {
203202
static void* nrn_fixed_step_thread(NrnThread* nth) {
204203
/* check thresholds and deliver all (including binqueue)
205204
events up to t+dt/2 */
206-
extern int secondorder;
207205
deliver_net_events(nth);
208206
nth->_t += .5 * nth->_dt;
209207

coreneuron/nrnoc/multicore.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3131
#include "coreneuron/nrnoc/nrnpthread.h"
3232
#include "coreneuron/nrnoc/multicore.h"
3333
#include "coreneuron/nrnmpi/nrnmpi.h"
34-
34+
#include "coreneuron/nrnoc/nrnoc_decl.h"
3535
/*
3636
Now that threads have taken over the actual_v, v_node, etc, it might
3737
be a good time to regularize the method of freeing, allocating, and
@@ -72,13 +72,6 @@ int nrn_nthread = 0;
7272
NrnThread* nrn_threads = NULL;
7373
void (*nrn_mk_transfer_thread_data_)();
7474

75-
extern int v_structure_change;
76-
extern int diam_changed;
77-
78-
extern void nrn_threads_free();
79-
extern void nrn_old_thread_save();
80-
extern double nrn_timeus();
81-
8275
static int nrn_thread_parallel_;
8376
static int table_check_cnt_;
8477
static ThreadDatum* table_check_;

coreneuron/nrnoc/nrnoc_aux.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ THE POSSIBILITY OF SUCH DAMAGE.
3030
#include <string.h>
3131
#include "coreneuron/nrnconf.h"
3232
#include "coreneuron/nrnoc/multicore.h"
33-
34-
extern void nrnmpi_finalize(void);
33+
#include "coreneuron/nrnmpi/nrnmpidec.h"
3534

3635
int stoprun;
37-
int nrn_nthread;
38-
NrnThread* nrn_threads;
3936
int v_structure_change;
4037
int diam_changed;
4138
#define MAXERRCOUNT 5
@@ -156,7 +153,6 @@ double hoc_Exp(double x) {
156153
* abort in case of missmatch
157154
*/
158155
void check_bbcore_write_version(const char* version) {
159-
extern int nrnmpi_myid;
160156

161157
if (strcmp(version, bbcore_write_version) != 0) {
162158
if (nrnmpi_myid == 0)

0 commit comments

Comments
 (0)