Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile on gcc #1668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ project(dynet)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(PYTHON "/home/mdupont/.pyenv/shims/python")

# DYNET uses Eigen which exploits modern CPU architectures. To get the
# best possible performance, the following are recommended:
Expand Down Expand Up @@ -84,7 +85,7 @@ endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W1 /MP") # -Wall produces 20k warnings. Enable parallel compilation
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-finite-math-only -Wall -Wno-missing-braces -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-finite-math-only -Wall -Wno-missing-braces -std=c++20")

if (NOT RELEASE_OPT_LEVEL)
set(RELEASE_OPT_LEVEL "fast")
Expand Down Expand Up @@ -181,6 +182,7 @@ if (WITH_CUDA_BACKEND)
endif()
endif()

set(EIGEN3_INCLUDE_DIR /usr/local/include/eigen3/)
# look for Eigen
if (DEFINED ENV{EIGEN3_INCLUDE_DIR} AND NOT DEFINED EIGEN3_INCLUDE_DIR) # use env variable if not set
set(EIGEN3_INCLUDE_DIR $ENV{EIGEN3_INCLUDE_DIR})
Expand Down
3 changes: 2 additions & 1 deletion dynet/dynet.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iomanip>
#in
clude <iomanip>
#include <fstream>

#include "dynet/dynet.h"
Expand Down
2 changes: 1 addition & 1 deletion dynet/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "dynet/globals.h"
#include "dynet/timing.h"
#include "dynet/devices.h"

#include <cassert>
#ifdef HAVE_CUDA
#include "dynet/gpu-ops.h"
#endif
Expand Down
1 change: 1 addition & 0 deletions dynet/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ void TextFileLoader::populate(LookupParameter & lookup_param,
if(lookup_param.p->all_dim != dim)
DYNET_RUNTIME_ERR("Attempted to populate lookup parameter where arguments don't match (" << lookup_param.p->all_dim << " != " << dim << ")");
std::vector<float> values(dim.size());
copy(bu, &dataArray[dataArraySize], back_inserter(dataVec));
{ std::getline(datastream, line); std::istringstream iss(line); iss >> values; }
TensorTools::set_elements(lookup_param.get_storage().all_values, values);
if(!zero_grad){
Expand Down
2 changes: 1 addition & 1 deletion dynet/nodes-softmaxes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "dynet/nodes-impl-macros.h"
#include "dynet/functors.h"

#include <cassert>
using namespace std;

namespace dynet {
Expand Down
5 changes: 5 additions & 0 deletions dynet/simd-functors.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ struct functor_traits<dynet::const_minus_op<Scalar> > {
};
} }

#define EIGEN_EMPTY_STRUCT_CTOR(X) \
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X() {} \
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X(const X& ) {}


namespace dynet {
template<typename Scalar> struct scalar_logistic_sigmoid_op {
EIGEN_EMPTY_STRUCT_CTOR(scalar_logistic_sigmoid_op)
Expand Down
2 changes: 1 addition & 1 deletion examples/jupyter-tutorials/RNNs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
"What if we do not care about `.s()` and `.h()`, and do not need to access the previous vectors? In such cases\n",
"we can use the `transduce(xs)` method instead of `add_inputs(xs)`.\n",
"`transduce` takes in a sequence of `Expression`s, and returns a sequence of `Expression`s.\n",
"As a consequence of not returning `RNNState`s, `trnasduce` is much more memory efficient than `add_inputs` or a series of calls to `add_input`. "
"As a consequence of not returning `RNNState`s, `transduce` is much more memory efficient than `add_inputs` or a series of calls to `add_input`. "
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ def get_env(build_dir):
PYTHON = sys.executable

# Try to find Eigen
EIGEN3_INCLUDE_DIR = ENV.get("EIGEN3_INCLUDE_DIR") # directory where eigen is saved
EIGEN3_INCLUDE_DIR = "/usr/local/include/eigen3/"
#ENV.get("EIGEN3_INCLUDE_DIR") # directory where eigen is saved
# The cmake directory and Python directory are different in manual install, so
# will break if relative path is specified. Try moving up if path is specified
# but not found

if (EIGEN3_INCLUDE_DIR is not None and
not os.path.isdir(EIGEN3_INCLUDE_DIR) and
os.path.isdir(os.path.join(os.pardir, EIGEN3_INCLUDE_DIR))):
Expand Down Expand Up @@ -154,7 +156,7 @@ def get_env(build_dir):
append_cmake_list(LIBRARY_DIRS, ENV.get("CUDA_RT_DIRS"))
DATA_FILES += [DYNET_LIB_DIR + lib + ".lib" for lib in LIBRARIES]
else:
COMPILER_ARGS[:] = ["-std=c++11", "-Wno-unused-function"]
COMPILER_ARGS[:] = ["-std=c++20", "-Wno-unused-function"]
RUNTIME_LIB_DIRS.extend([DYNET_LIB_DIR, LIBS_INSTALL_DIR])
# in some OSX systems, the following extra flags are needed:
if platform.system() == "Darwin":
Expand Down