Skip to content

Commit 8ec0122

Browse files
authored
Merge pull request #30 from modern-fortran/fpm
Enable building with fpm
2 parents 7c6d666 + eda4247 commit 8ec0122

21 files changed

+47
-21
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES Cray)
7878
endif()
7979

8080
# library to archive (libneural.a)
81-
add_library(neural src/lib/mod_activation.f90 src/lib/mod_io.f90 src/lib/mod_kinds.f90 src/lib/mod_layer.f90 src/lib/mod_mnist.f90 src/lib/mod_network.f90 src/lib/mod_parallel.f90 src/lib/mod_random.f90)
81+
add_library(neural src/mod_activation.f90 src/mod_io.f90 src/mod_kinds.f90 src/mod_layer.f90 src/mod_mnist.f90 src/mod_network.f90 src/mod_parallel.f90 src/mod_random.f90)
8282

8383
# Remove leading or trailing whitespace
8484
string(REGEX REPLACE "^ | $" "" LIBS "${LIBS}")
8585

8686
# tests
8787
enable_testing()
8888
foreach(execid mnist network_save network_sync set_activation_function)
89-
add_executable(test_${execid} src/tests/test_${execid}.f90)
89+
add_executable(test_${execid} test/test_${execid}.f90)
9090
target_link_libraries(test_${execid} neural ${LIBS})
9191
add_test(test_${execid} bin/test_${execid})
9292
endforeach()
9393

9494
foreach(execid mnist mnist_epochs save_and_load simple sine)
95-
add_executable(example_${execid} src/tests/example_${execid}.f90)
95+
add_executable(example_${execid} example/example_${execid}.f90)
9696
target_link_libraries(example_${execid} neural ${LIBS})
9797
add_test(example_${execid} bin/example_${execid})
9898
endforeach()

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2020 Milan Curcic and neural-fortran contributors
3+
Copyright (c) 2018-2021 neural-fortran contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ Read the paper [here](https://arxiv.org/abs/1902.06714).
88

99
* [Features](https://github.com/modern-fortran/neural-fortran#features)
1010
* [Getting started](https://github.com/modern-fortran/neural-fortran#getting-started)
11-
- [Building in serial mode](https://github.com/modern-fortran/neural-fortran#building-in-serial-mode)
12-
- [Building in parallel mode](https://github.com/modern-fortran/neural-fortran#building-in-parallel-mode)
13-
- [Building with a different compiler](https://github.com/modern-fortran/neural-fortran#building-with-a-different-compiler)
14-
- [Building with BLAS or MKL](https://github.com/modern-fortran/neural-fortran#building-with-blas-or-mkl)
15-
- [Building in double or quad precision](https://github.com/modern-fortran/neural-fortran#building-in-double-or-quad-precision)
16-
- [Building in debug mode](https://github.com/modern-fortran/neural-fortran#building-in-debug-mode)
11+
- [Building with fpm](https://github.com/modern-fortran/neural-fortran#building-with-fpm)
12+
- [Building with CMake](https://github.com/modern-fortran/neural-fortran#building-with-cmake)
1713
* [Examples](https://github.com/modern-fortran/neural-fortran#examples)
1814
- [Creating a network](https://github.com/modern-fortran/neural-fortran#creating-a-network)
1915
- [Training the network](https://github.com/modern-fortran/neural-fortran#training-the-network)
2016
- [Saving and loading from file](https://github.com/modern-fortran/neural-fortran#saving-and-loading-from-file)
2117
- [MNIST training example](https://github.com/modern-fortran/neural-fortran#mnist-training-example)
22-
* [Contributing](https://github.com/modern-fortran/neural-fortran#contributing)
23-
* [Related projects](https://github.com/modern-fortran/neural-fortran#related-projects)
18+
* [Contributing](https://github.com/modern-fortran/neural-fortran#contributing)
19+
* [Related projects](https://github.com/modern-fortran/neural-fortran#related-projects)
2420

2521
## Features
2622

@@ -36,18 +32,41 @@ Get the code:
3632

3733
```
3834
git clone https://github.com/modern-fortran/neural-fortran
35+
cd neural-fortran
3936
```
4037

4138
Dependencies:
4239

4340
* Fortran 2018-compatible compiler
44-
* OpenCoarrays (optional, for parallel execution, gfortran only)
41+
* OpenCoarrays (optional, for parallel execution, GFortran only)
4542
* BLAS, MKL (optional)
4643

47-
### Building in serial mode
44+
### Building with fpm
45+
46+
#### Building in serial mode
47+
48+
```
49+
fpm build --flag "-cpp -O3 -ffast-math fcoarrays=single"
50+
```
51+
52+
#### Building in parallel mode
53+
54+
If you use GFortran and want to run neural-fortran in parallel,
55+
you must first install [OpenCoarrays](https://github.com/sourceryinstitute/OpenCoarrays).
56+
Once installed, use the compiler wrappers `caf` and `cafrun` to build and execute
57+
in parallel, respectively:
58+
59+
```
60+
fpm build --compiler caf --flag "-cpp -DCAF -O3 -ffast-math"
61+
```
62+
63+
See [Fortran Package Manager](https://github.com/fortran-lang/fpm) for more info on fpm.
64+
65+
### Building with CMake
66+
67+
#### Building in serial mode
4868

4969
```
50-
cd neural-fortran
5170
mkdir build
5271
cd build
5372
cmake .. -DSERIAL=1
@@ -56,20 +75,21 @@ make
5675

5776
Tests and examples will be built in the `bin/` directory.
5877

59-
### Building in parallel mode
78+
#### Building in parallel mode
6079

61-
If you use gfortran and want to build neural-fortran in parallel mode,
80+
If you use GFortran and want to run neural-fortran in parallel,
6281
you must first install [OpenCoarrays](https://github.com/sourceryinstitute/OpenCoarrays).
6382
Once installed, use the compiler wrappers `caf` and `cafrun` to build and execute
6483
in parallel, respectively:
6584

85+
6686
```
6787
FC=caf cmake ..
6888
make
6989
cafrun -n 4 bin/example_mnist # run MNIST example on 4 cores
7090
```
7191

72-
### Building with a different compiler
92+
#### Building with a different compiler
7393

7494
If you want to build with a different compiler, such as Intel Fortran,
7595
specify `FC` when issuing `cmake`:
@@ -78,7 +98,7 @@ specify `FC` when issuing `cmake`:
7898
FC=ifort cmake ..
7999
```
80100

81-
### Building with BLAS or MKL
101+
#### Building with BLAS or MKL
82102

83103
To use an external BLAS or MKL library for `matmul` calls,
84104
run cmake like this:
@@ -91,7 +111,7 @@ where the value of `-DBLAS` should point to the desired BLAS implementation,
91111
which has to be available in the linking path.
92112
This option is currently available only with gfortran.
93113

94-
### Building in double or quad precision
114+
#### Building in double or quad precision
95115

96116
By default, neural-fortran is built in single precision mode
97117
(32-bit floating point numbers). Alternatively, you can configure to build
@@ -107,7 +127,7 @@ or
107127
cmake .. -DREAL=128
108128
```
109129

110-
### Building in debug mode
130+
#### Building in debug mode
111131

112132
To build with debugging flags enabled, type:
113133

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

fpm.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "neural-fortran"
2+
version = "0.1.0"
3+
license = "MIT"
4+
author = "Milan Curcic"
5+
maintainer = "[email protected]"
6+
copyright = "Copyright 2018-2021, neural-fortran contributors"
File renamed without changes.

0 commit comments

Comments
 (0)