Skip to content

Commit 1f67e23

Browse files
committed
compiling with opencilk
1 parent 6718fdc commit 1f67e23

8 files changed

+56
-37
lines changed

Makefile

+30-21
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,64 @@
1-
CILK = /opt/intel/composer_xe_2013.5.198/compiler
2-
INCADD = -I$(CILK)/include -I$(CILK)/examples/include
3-
LIBADD = -L$(CILK)/lib/intel64
1+
CILK?=0
2+
NATIVE?=1
3+
OPT?=3
4+
5+
CFLAGS := -Wall -Wextra -O$(OPT) -g -std=c++17 -gdwarf-4 -fno-exceptions
6+
7+
ifeq ($(NATIVE),1)
8+
CFLAGS += -march=native
9+
endif
10+
11+
ifeq ($(CILK),1)
12+
CFLAGS += -fopencilk
13+
endif
14+
15+
DEFINES := -DCILK=$(CILK)
416

5-
GCCOPT = -O2 -fno-rtti -fno-exceptions # -ftree-vectorize
6-
INTELOPT = -O2 -no-ipo -fno-rtti -fno-exceptions -parallel -restrict -std=c++11 -xAVX -no-prec-div #-fno-inline-functions
7-
DEB = -g -DNOBM -O0 -parallel -restrict -std=c++11
817

918
seqsym: sym_spmv_test.cpp csbsym.cpp csbsym.h utility.h friends.h SSEspmv.o
10-
icpc -cilk-serialize $(INCADD) $(INTELOPT) -o seqsym sym_spmv_test.cpp SSEspmv.o
19+
$(CXX) $(CFLAGS) $(DEFINES) -o seqsym sym_spmv_test.cpp SSEspmv.o
1120

1221
parsym: sym_spmv_test.cpp csbsym.cpp csbsym.h utility.h friends.h SSEspmv.o
13-
icpc $(INCADD) $(DEB) -o parsym sym_spmv_test.cpp SSEspmv.o
22+
$(CXX) $(CFLAGS) $(DEFINES) -o parsym sym_spmv_test.cpp SSEspmv.o
1423

1524
symanal: sym_spmv_test.cpp csbsym.cpp csbsym.h utility.h friends.h SSEspmv.o
16-
icpc -DSTATS $(INCADD) $(INTELOPT) -o symanal sym_spmv_test.cpp SSEspmv.o -lcilkutil
25+
$(CXX) $(CFLAGS) $(DEFINES) -o symanal sym_spmv_test.cpp SSEspmv.o -lcilkutil
1726

1827
seqspmv: csb_spmv_test.cpp bicsb.cpp bicsb.h bmcsb.cpp bmcsb.h friends.h utility.h SSEspmv.o
19-
icpc -cilk-serialize $(INCADD) $(INTELOPT) -o seqspmv csb_spmv_test.cpp SSEspmv.o
28+
$(CXX) $(CFLAGS) $(DEFINES) -o seqspmv csb_spmv_test.cpp SSEspmv.o
2029

2130
parspmv: csb_spmv_test.cpp bicsb.cpp bicsb.h bmcsb.cpp bmcsb.h friends.h utility.h SSEspmv.o
22-
icpc $(INCADD) $(INTELOPT) -o parspmv csb_spmv_test.cpp SSEspmv.o
31+
$(CXX) $(CFLAGS) $(DEFINES) -o parspmv csb_spmv_test.cpp SSEspmv.o
2332

2433
parspmv_nobm: csb_spmv_test.cpp bicsb.cpp bicsb.h friends.h utility.h
25-
icpc $(INCADD) $(INTELOPT) -DNOBM -o parspmv_nobm csb_spmv_test.cpp
34+
$(CXX) $(CFLAGS) $(DEFINES) -DNOBM -o parspmv_nobm csb_spmv_test.cpp
2635

2736
parspmvt: csb_spmvt_test.cpp bicsb.cpp bicsb.h utility.h friends.h
28-
icpc $(INCADD) $(INTELOPT) -o parspmvt csb_spmvt_test.cpp
37+
$(CXX) $(CFLAGS) $(DEFINES) -o parspmvt csb_spmvt_test.cpp
2938

3039
both_d: both_test.cpp bicsb.cpp bicsb.h utility.h friends.h
31-
icpc $(INCADD) $(INTELOPT) -o both_d both_test.cpp
40+
$(CXX) $(CFLAGS) $(DEFINES) -o both_d both_test.cpp
3241

3342
both_s: both_test.cpp bicsb.cpp bicsb.h utility.h friends.h
34-
icpc $(INCADD) $(INTELOPT) -DSINGLEPRECISION -o both_s both_test.cpp
43+
$(CXX) $(CFLAGS) $(DEFINES) -DSINGLEPRECISION -o both_s both_test.cpp
3544

3645
spmm_dall: spmm_test.cpp bicsb.cpp bicsb.h utility.h friends.h
3746
for number in 4 8 12 16 24 32 40 48 56 64; do \
38-
echo "icpc $(INCADD) $(INTELOPT) -DRHSDIM=$$number -o spmm_d$$number spmm_test.cpp"; \
39-
icpc $(INCADD) $(INTELOPT) -DRHSDIM=$$number -o spmm_d$$number spmm_test.cpp; \
47+
echo "$(CXX) $(CFLAGS) $(DEFINES) -DRHSDIM=$$number -o spmm_d$$number spmm_test.cpp"; \
48+
$(CXX) $(CFLAGS) $(DEFINES) -DRHSDIM=$$number -o spmm_d$$number spmm_test.cpp; \
4049
done;
4150

4251
spmm_a: spmm_test.cpp bicsb.cpp bicsb.h utility.h friends.h
43-
icpc $(INCADD) $(INTELOPT) -DSINGLEPRECISION -S -fcode-asm -vec_report6 spmm_test.cpp
52+
$(CXX) $(CFLAGS) $(DEFINES) -DSINGLEPRECISION -S -fcode-asm -vec_report6 spmm_test.cpp
4453

4554
spmm_sall: spmm_test.cpp bicsb.cpp bicsb.h utility.h friends.h
4655
for number in 4 8 12 16 24 32 40 48 56 64; do \
47-
echo "icpc $(INCADD) $(INTELOPT) -DSINGLEPRECISION -DRHSDIM=$$number -o spmm_s$$number spmm_test.cpp"; \
48-
icpc $(INCADD) $(INTELOPT) -DSINGLEPRECISION -DRHSDIM=$$number -o spmm_s$$number spmm_test.cpp; \
56+
echo "$(CXX) $(CFLAGS) $(DEFINES) -DSINGLEPRECISION -DRHSDIM=$$number -o spmm_s$$number spmm_test.cpp"; \
57+
$(CXX) $(CFLAGS) $(DEFINES) -DSINGLEPRECISION -DRHSDIM=$$number -o spmm_s$$number spmm_test.cpp; \
4958
done;
5059

5160
SSEspmv.o: SSEspmv.cpp
52-
g++ -DAMD $(GCCOPT) -march=amdfam10 -c SSEspmv.cpp
61+
$(CXX) $(CFLAGS) $(DEFINES) -c SSEspmv.cpp
5362

5463
clean:
5564
rm -f seqspmv

bicsb.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,9 @@ ofstream & BiCsb<NT, IT>::PrintStats(ofstream & outfile) const
13501350
outfile << "## Number of real blocks is "<< ntop << endl;
13511351
outfile << "## Row imbalance is " << RowImbalance(*this) << endl;
13521352
outfile << "## Col imbalance is " << ColImbalance(*this) << endl;
1353+
#ifdef STATS
13531354
outfile << "## Block parallel calls is " << blockparcalls.get_value() << endl;
1354-
1355+
#endif
13551356
std::vector<int> blocksizes(ntop);
13561357
for(IT i=0; i<nbr; ++i)
13571358
{

both_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace std;
3131

3232
int main(int argc, char* argv[])
3333
{
34-
#ifndef CILK_STUB
34+
#if CILK==1
3535
int gl_nworkers = __cilkrts_get_nworkers();
3636
#else
3737
int gl_nworkers = 0;

csb_spmv_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace std;
3232

3333
int main(int argc, char* argv[])
3434
{
35-
#ifndef CILK_STUB
35+
#if CILK==1
3636
int gl_nworkers = __cilkrts_get_nworkers();
3737
#else
3838
int gl_nworkers = 0;

csb_spmvt_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ INDEXTYPE flops;
3030

3131
int main(int argc, char* argv[])
3232
{
33-
#ifndef CILK_STUB
33+
#if CILK==1
3434
int gl_nworkers = __cilkrts_get_nworkers();
3535
#else
3636
int gl_nworkers = 0;

spmm_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void VerifyMM (vector< array<NT,DIM>, ALLOC > & control, vector< array<NT,DIM>,
105105

106106
int main(int argc, char* argv[])
107107
{
108-
#ifndef CILK_STUB
108+
#if CILK==1
109109
int gl_nworkers = __cilkrts_get_nworkers();
110110
#else
111111
int gl_nworkers = 0;

sym_spmv_test.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
#include "utility"
1212
#include "timer.gettimeofday.c"
13-
#include "cilk_util.h"
13+
14+
#ifndef RHSDIM
15+
#define RHSDIM 16
16+
#endif
17+
#define ALIGN 32
1418

1519
#include "triple.h"
1620
#include "csc.h"
@@ -33,7 +37,7 @@ using namespace std;
3337

3438
int main(int argc, char* argv[])
3539
{
36-
#ifndef CILK_STUB
40+
#if CILK==1
3741
int gl_nworkers = WORKERS;
3842
#else
3943
int gl_nworkers = 0;
@@ -110,7 +114,7 @@ int main(int argc, char* argv[])
110114
return 1;
111115
}
112116

113-
long tstart = cilk_get_time(); // start timer
117+
long tstart = get_time(); // start timer
114118
cout << "Reading matrix with dimensions: "<< m << "-by-" << n <<" having "<< nnz << " nonzeros" << endl;
115119

116120
INDEXTYPE * rowindices = new INDEXTYPE[nnz];
@@ -127,7 +131,7 @@ int main(int argc, char* argv[])
127131
return -1;
128132
}
129133

130-
long tend = cilk_get_time(); // end timer
134+
long tend = get_time(); // end timer
131135
cout<< "Reading matrix in binary took " << ((VALUETYPE) (tend-tstart)) /1000 << " seconds" <<endl;
132136
fclose(f);
133137

@@ -152,7 +156,7 @@ int main(int argc, char* argv[])
152156
infile.unget();
153157
infile >> m >> n >> nnz; // #{rows}-#{cols}-#{nonzeros}
154158

155-
long tstart = cilk_get_time(); // start timer
159+
long tstart = get_time(); // start timer
156160
Triple<VALUETYPE, INDEXTYPE> * triples = new Triple<VALUETYPE, INDEXTYPE>[nnz];
157161

158162
if (infile.is_open())
@@ -167,7 +171,7 @@ int main(int argc, char* argv[])
167171
}
168172
assert(cnz == nnz);
169173
}
170-
long tend = cilk_get_time(); // end timer
174+
long tend = get_time(); // end timer
171175
cout<< "Reading matrix in ascii took " << ((double) (tend-tstart)) /1000 << " seconds" <<endl;
172176

173177
cout << "converting to csc ... " << endl;

utility.h

+10-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace std;
2929
#define UNROLL 1
3030
#endif
3131

32-
#ifndef CILK_STUB
32+
#if CILK==1
3333
#ifdef __cplusplus
3434
extern "C" {
3535
#endif
@@ -41,16 +41,15 @@ extern "C" {
4141
* full frame to determine this.
4242
*/
4343

44-
CILK_EXPORT __CILKRTS_NOTHROW
45-
int __cilkrts_synched(void);
44+
#define __cilkrts_synched() (0)
4645

4746
#ifdef __cplusplus
4847
} // extern "C"
4948
#endif
50-
#else /* CILK_STUB */
49+
#else /* CILK==1 */
5150
/* Stubs for the api functions */
5251
#define __cilkrts_synched() (1)
53-
#endif /* CILK_STUB */
52+
#endif /* CILK */
5453

5554
#ifdef STATS
5655
#include <cilk/reducer_opadd.h>
@@ -503,5 +502,11 @@ inline unsigned int getDivident(unsigned int n, unsigned int d)
503502
return n;
504503
}
505504

505+
static long get_time() {
506+
struct timeval st;
507+
gettimeofday(&st, NULL);
508+
return st.tv_sec * 1000000 + st.tv_usec;
509+
}
510+
506511
#endif
507512

0 commit comments

Comments
 (0)