Автор Тема: Как скомпилировать файл с #include <mpi.h>?  (Прочитано 5421 раз)

Павелъ

  • Гость
Доброго времени суток.
Задали лабораторную по распараллеливанию средствами библиотеки mpi.
Установил кучу пакетов, в которых упоминается mpi. Никаких результатов. Программа не хочет компилироваться. В /usr/include/... mpi тоже не нашёл.
Что надо поставить, чтобы скомпилить программу?

Оффлайн yaleks

  • Мастер
  • ***
  • Сообщений: 6 234
Установил кучу пакетов, в которых упоминается mpi. Никаких результатов.
а openmpi-devel не забыли?
Его и openmpi должно быть достаточно.

Ну knem можно также для максимальной производительности на одном хосте (но надо чуток поднастроить).

Павелъ

  • Гость
Установил кучу пакетов, в которых упоминается mpi. Никаких результатов.
а openmpi-devel не забыли?
Его и openmpi должно быть достаточно.

Ну knem можно также для максимальной производительности на одном хосте (но надо чуток поднастроить).

[root@comp-core-i7-3520m-6b607c ~]# apt-get install openmpi-devel
Чтение списков пакетов... Завершено
Построение дерева зависимостей... Завершено
Последняя версия openmpi-devel уже установлена.
0 будет обновлено, 0 новых установлено, 0 пакетов будет удалено и 0 не будет обновлено.
[root@comp-core-i7-3520m-6b607c ~]# apt-get install openmpi
Чтение списков пакетов... Завершено
Построение дерева зависимостей... Завершено
Последняя версия openmpi уже установлена.
0 будет обновлено, 0 новых установлено, 0 пакетов будет удалено и 0 не будет обновлено.

Оффлайн ASte

  • Мастер
  • ***
  • Сообщений: 1 550
а что говорит
find / -iname mpi.h 2>/dev/null
?

Павелъ

  • Гость
а что говорит
find / -iname mpi.h 2>/dev/null
?

/usr/lib/openmpi/include/mpi.h
/usr/lib/openmpi-udapl-threads/include/mpi.h
/usr/lib64/openmpi/include/mpi.h
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h

Попробовал скомпилить с каждой из найденных:

[pavel@comp-core-i7-3520m-6b607c integral]$ g++ -o integral integral.cxx
In file included from /usr/lib/openmpi/include/mpi.h:1886:0,
                 from integral.cxx:74:
/usr/lib/openmpi/include/openmpi/ompi/mpi/cxx/mpicxx.h:33:17: fatal error: mpi.h: Нет такого файла или каталога
compilation terminated.
[pavel@comp-core-i7-3520m-6b607c integral]$ g++ -o integral integral.cxx
In file included from /usr/lib/openmpi-udapl-threads/include/mpi.h:1886:0,
                 from integral.cxx:74:
/usr/lib/openmpi-udapl-threads/include/openmpi/ompi/mpi/cxx/mpicxx.h:33:17: fatal error: mpi.h: Нет такого файла или каталога
compilation terminated.
[pavel@comp-core-i7-3520m-6b607c integral]$ g++ -o integral integral.cxx
In file included from /usr/lib64/openmpi/include/mpi.h:2087:0,
                 from integral.cxx:74:
/usr/lib64/openmpi/include/openmpi/ompi/mpi/cxx/mpicxx.h:35:17: fatal error: mpi.h: Нет такого файла или каталога
compilation terminated.
[pavel@comp-core-i7-3520m-6b607c integral]$ g++ -o integral integral.cxx
In file included from integral.cxx:74:0:
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:72:23: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:82:1: error: ‘u32’ does not name a type
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:90:30: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:93:30: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:98:30: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:99:32: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:104:1: error: ‘ulong’ does not name a type
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:111:42: error: ‘ulong’ has not been declared
/usr/src/linux-3.14.54-std-def-alt0.M70P.1/include/linux/mpi.h:124:23: error: ‘ulong’ has not been declared
integral.cxx: In function ‘int main(int, char**)’:
integral.cxx:81:20: warning: overflow in implicit constant conversion [-Woverflow]
integral.cxx:82:25: error: ‘MPI_Init’ was not declared in this scope
integral.cxx:83:18: error: ‘MPI_COMM_WORLD’ was not declared in this scope
integral.cxx:83:39: error: ‘MPI_Comm_rank’ was not declared in this scope
integral.cxx:84:39: error: ‘MPI_Comm_size’ was not declared in this scope
integral.cxx:92:31: error: ‘MPI_DOUBLE’ was not declared in this scope
integral.cxx:92:43: error: ‘MPI_SUM’ was not declared in this scope
integral.cxx:92:69: error: ‘MPI_Reduce’ was not declared in this scope
integral.cxx:93:30: error: ‘MPI_Barrier’ was not declared in this scope
integral.cxx:95:18: error: ‘MPI_Finalize’ was not declared in this scope

Пример стандартной программы взял с http://www.moodle.ipm.kstu.ru/mod/page/view.php?id=9610

Оффлайн yaleks

  • Мастер
  • ***
  • Сообщений: 6 234
Так MPI компилируют при помощи mpiCC обычно - https://www.open-mpi.org/faq/?category=mpi-apps

P.S. вам ничего не объяснили что-ли преподы или на винде показывали?

Павелъ

  • Гость
Так MPI компилируют при помощи mpiCC обычно - https://www.open-mpi.org/faq/?category=mpi-apps

P.S. вам ничего не объяснили что-ли преподы или на винде показывали?

пример для виндовс, но запустить надо будет в Linux

Павелъ

  • Гость
mpiCC, mpicxx, mpic++ эти команды не работают.
mvapich установил

Павелъ

  • Гость
[pavel@comp-core-i7-3520m-6b607c integral]$ g++ -lmpi integral.cxx -o integral
integral.cxx: In function ‘int main(int, char**)’:
integral.cxx:81:20: warning: overflow in implicit constant conversion [-Woverflow]
integral.cxx:82:25: error: ‘MPI_Init’ was not declared in this scope
integral.cxx:83:18: error: ‘MPI_COMM_WORLD’ was not declared in this scope
integral.cxx:83:39: error: ‘MPI_Comm_rank’ was not declared in this scope
integral.cxx:84:39: error: ‘MPI_Comm_size’ was not declared in this scope
integral.cxx:92:31: error: ‘MPI_DOUBLE’ was not declared in this scope
integral.cxx:92:43: error: ‘MPI_SUM’ was not declared in this scope
integral.cxx:92:69: error: ‘MPI_Reduce’ was not declared in this scope
integral.cxx:93:30: error: ‘MPI_Barrier’ was not declared in this scope
integral.cxx:95:18: error: ‘MPI_Finalize’ was not declared in this scope
[pavel@comp-core-i7-3520m-6b607c integral]$ mpicc integral.cxx -o integral
bash: mpicc: команда не найдена
[pavel@comp-core-i7-3520m-6b607c integral]$

Пример для Linux с сайта http://www.moodle.ipm.kstu.ru/mod/page/view.php?id=9610. Не работает(((

Оффлайн yaleks

  • Мастер
  • ***
  • Сообщений: 6 234
что-то я не понимаю что у вас за пример. попробуйте   https://github.com/open-mpi/ompi/blob/master/examples/hello_c.c
Это на C , не C++

Павелъ

  • Гость
что-то я не понимаю что у вас за пример. попробуйте   https://github.com/open-mpi/ompi/blob/master/examples/hello_c.c
Это на C , не C++

Не работает, и не должен. Откуда он возьмёт #include "mpi.h"?

Оффлайн yaleks

  • Мастер
  • ***
  • Сообщений: 6 234
что-то я не понимаю что у вас за пример. попробуйте   https://github.com/open-mpi/ompi/blob/master/examples/hello_c.c
Это на C , не C++

Не работает, и не должен. Откуда он возьмёт #include "mpi.h"?
# rpm -qf /usr/lib/openmpi/bin/mpicc
openmpi-devel-1.3.3-alt1

[user@test ~]$ source /usr/lib/openmpi/bin/mpivars.sh
[user@test ~]$ mpicc test.c -o test
test.c: In function ‘main’:
test.c:9: warning: integer constant is too large for ‘long’ type
test.c:9: warning: overflow in implicit constant conversion
[user@test ~]$ ldd ./test
        linux-gate.so.1 =>  (0xb77ec000)
        libmpi.so.0 => /usr/lib/openmpi/lib/libmpi.so.0 (0xb775a000)
        libopen-rte.so.0 => /usr/lib/openmpi/lib/libopen-rte.so.0 (0xb7718000)
        libopen-pal.so.0 => /usr/lib/openmpi/lib/libopen-pal.so.0 (0xb76ad000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7684000)
        libnsl.so.1 => /lib/libnsl.so.1 (0xb766a000)
        libutil.so.1 => /lib/libutil.so.1 (0xb7666000)
        libm.so.6 => /lib/libm.so.6 (0xb763c000)
        libc.so.6 => /lib/libc.so.6 (0xb74e3000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb74ca000)
        /lib/ld-linux.so.2 (0xb77ed000)

Павелъ

  • Гость
[root@comp-core-i7-3520m-6b607c mpi]# rpm -qf /usr/lib/openmpi/bin/mpicc
openmpi1_4-devel-1.4.5-alt3.M70P.1

[pavel@comp-core-i7-3520m-6b607c integral]$ source /usr/lib/openmpi/bin/mpivars.sh
[pavel@comp-core-i7-3520m-6b607c integral]$ mpicc integral.cxx -o integral
integral.cxx: In function ‘int main(int, char**)’:
integral.cxx:106:18: error: ‘MPI_MAX_LIBRARY_VERSION_STRING’ was not declared in this scope
integral.cxx:111:29: error: ‘version’ was not declared in this scope
integral.cxx:111:42: error: ‘MPI_Get_library_version’ was not declared in this scope