Giter Site home page Giter Site logo

cps's People

Contributors

kaityo256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cps's Issues

unique_ptr<char[]>を使う

Qiitaの記事を読んできました.

cps/cps.cpp

Line 129 in 7b8667c

std::unique_ptr<char> buf(new char[len]);

では,std::unique_ptr<char>new char[len]を受けていますが,これはdelete []ではなくdeleteを実行するので正しくメモリが解放されません.
std::unique_ptr<char[]>を使用すべきかと思います.

参考: https://cpprefjp.github.io/reference/memory/unique_ptr.html
の配列版・「new[]演算子で~」の部分

コンパイルができない

2/21版のコードで以下のエラーによりコンパイルが通りません.

[user@host cps]$ make
mpicxx -Wall -Wextra -std=c++11 cps.cpp -o cps
cps.cpp: In function ‘void worker(int)’:
cps.cpp:112:5: error: ‘unique_ptr’ is not a member of ‘std’
     std::unique_ptr<char[]> buf(new char[len]);
     ^~~
cps.cpp:112:21: error: expected primary-expression before ‘char’
     std::unique_ptr<char[]> buf(new char[len]);
                     ^~~~
cps.cpp:113:14: error: ‘buf’ was not declared in this scope
     MPI_Recv(buf.get(), len, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &st);
              ^~~
makefile:7: recipe for target 'cps' failed
make: *** [cps] Error 1

当方のコンパイラは,CentOS7.6上のSCLのdevtoolset-6をOpenMPI 4.0.2でコンパイルしたものになります.

[user@host cps]$ mpixx -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-6/root/usr/bin/c++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-6/root/usr --mandir=/opt/rh/devtoolset-6/root/usr/share/man --infodir=/opt/rh/devtoolset-6/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-6.3.1-20170216/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.