From dbabc099d66902daa094478024a8a331822b78bc Mon Sep 17 00:00:00 2001 From: Dominik 'Rathann' Mierzejewski Date: Sep 24 2015 09:12:46 +0000 Subject: enable OpenCL support (x86 and single precision only for now) --- diff --git a/gromacs-opencl.patch b/gromacs-opencl.patch new file mode 100644 index 0000000..9082885 --- /dev/null +++ b/gromacs-opencl.patch @@ -0,0 +1,24 @@ +diff -up gromacs-5.1/cmake/gmxManageOpenCL.cmake.opencl gromacs-5.1/cmake/gmxManageOpenCL.cmake +--- gromacs-5.1/cmake/gmxManageOpenCL.cmake.opencl 2015-08-13 13:48:09.000000000 +0200 ++++ gromacs-5.1/cmake/gmxManageOpenCL.cmake 2015-09-23 22:06:39.853725998 +0200 +@@ -59,7 +59,7 @@ endif() + + # Yes Virginia, Darwin kernel version 14.4 corresponds to OS X 10.4. + if(APPLE AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS "14.4") +- message(WARNING "OS X prior to version 10.10.4 produces incorrect AMD OpenCL code at runtime. You will not be able to use AMD GPUs on this host unless you upgrade your operating system."); ++ message(WARNING "OS X prior to version 10.10.4 produces incorrect AMD OpenCL code at runtime. You will not be able to use AMD GPUs on this host unless you upgrade your operating system.") + endif() + + add_definitions(${OPENCL_DEFINITIONS}) +diff -up gromacs-5.1/src/programs/mdrun/tests/moduletest.cpp.opencl gromacs-5.1/src/programs/mdrun/tests/moduletest.cpp +--- gromacs-5.1/src/programs/mdrun/tests/moduletest.cpp.opencl 2015-06-22 15:17:54.000000000 +0200 ++++ gromacs-5.1/src/programs/mdrun/tests/moduletest.cpp 2015-09-23 23:01:35.456564790 +0200 +@@ -220,7 +220,7 @@ SimulationRunner::callMdrun(const Comman + #ifdef GMX_MPI + # ifdef GMX_GPU + # ifdef GMX_THREAD_MPI +- int numGpusNeeded = g_numThreads; ++ int numGpusNeeded = 1; + # else /* Must be real MPI */ + int numGpusNeeded = gmx_node_num(); + # endif diff --git a/gromacs.spec b/gromacs.spec index 0ea6ea9..4569a0c 100644 --- a/gromacs.spec +++ b/gromacs.spec @@ -4,6 +4,7 @@ %global with_openmpi 0 %endif %global execstack_excludearch aarch64 ppc64 ppc64le s390 s390x +%global opencl_arches i686 x86_64 %global simd None %ifarch x86_64 @@ -42,6 +43,8 @@ Patch0: gromacs-dssp-path.patch # fix compilation on ppc64(le) with VSX SIMD # http://redmine.gromacs.org/issues/1808 Patch1: gromacs-vsx.patch +# fix gmxManageOpenCL.cmake syntax error and MPI tests +Patch2: gromacs-opencl.patch BuildRequires: cmake BuildRequires: atlas-devel >= 3.10.1 BuildRequires: boost-devel @@ -50,6 +53,13 @@ BuildRequires: gsl-devel BuildRequires: libxml2-devel BuildRequires: libX11-devel BuildRequires: motif-devel +%ifarch %{opencl_arches} +BuildRequires: ocl-icd-devel +BuildRequires: opencl-headers +# use CPU-based OpenCL implementation for build +BuildRequires: pocl +Requires: gromacs-opencl = %{version}-%{release} +%endif # To get rid of executable stacks %ifnarch %{execstack_excludearch} BuildRequires: /usr/bin/execstack @@ -92,6 +102,25 @@ and solid state physics. This package includes architecture independent data and HTML documentation. +%package opencl +Summary: GROMACS OpenCL kernels +ExclusiveArch: %{opencl_arches} +# suggest installing a GPU-based OpenCL implementation +Suggests: beignet +Suggests: mesa-libOpenCL +# or at least a CPU-based one +Suggests: pocl + +%description opencl +GROMACS is a versatile and extremely well optimized package to perform +molecular dynamics computer simulations and subsequent trajectory analysis. +It is developed for biomolecules like proteins, but the extremely high +performance means it is used also in several other field like polymer chemistry +and solid state physics. + +This package includes the OpenCL kernels. + + %package doc Summary: GROMACS manual BuildArch: noarch @@ -141,6 +170,9 @@ This package contains libraries needed for operation of GROMACS. %package openmpi Summary: GROMACS Open MPI binaries and libraries Requires: gromacs-common = %{version}-%{release} +%ifarch %{opencl_arches} +Requires: gromacs-opencl = %{version}-%{release} +%endif Requires: gromacs-openmpi-libs = %{version}-%{release} BuildRequires: openmpi-devel @@ -192,6 +224,9 @@ You may need it if you want to write your own analysis programs. %package mpich Summary: GROMACS MPICH binaries and libraries Requires: gromacs-common = %{version}-%{release} +%ifarch %{opencl_arches} +Requires: gromacs-opencl = %{version}-%{release} +%endif Requires: gromacs-mpich-libs = %{version}-%{release} %description mpich @@ -273,6 +308,9 @@ script. %setup -q %patch0 -p1 -b .dssp %patch1 -p1 -b .vsx +%ifarch %{opencl_arches} +%patch2 -p1 -b .opencl +%endif mkdir {serial,mpich,openmpi}{,_d} %build @@ -295,6 +333,10 @@ export LDFLAGS="-L%{_libdir}/atlas" -DGMX_SIMD=%{simd} \\\ -DGMX_X11=ON +%ifarch %{opencl_arches} +# OpenCL is available for single precision only +%global single -DGMX_GPU=ON -DGMX_USE_OPENCL=ON +%endif %global double -DGMX_DOUBLE=ON %global mpi -DGMX_BUILD_MDRUN_ONLY=ON -DGMX_MPI=ON -DGMX_THREAD_MPI=OFF -DGMX_DEFAULT_SUFFIX=OFF @@ -303,7 +345,7 @@ export LDFLAGS="-L%{_libdir}/atlas" for p in '' _d ; do SUFFIXCONF="-D GMX_BINARY_SUFFIX=${MPI_SUFFIX}${p} -D GMX_LIBS_SUFFIX=${MPI_SUFFIX}${p}" cd openmpi${p} -%cmake %{defopts} %{mpi} $SUFFIXCONF $(test -n "$p" && echo %{double}) .. +%cmake %{defopts} %{mpi} $SUFFIXCONF $(test -n "$p" && echo %{double} || echo %{?single}) .. make VERBOSE=1 %{?_smp_mflags} cd .. done @@ -314,7 +356,7 @@ done for p in '' _d ; do SUFFIXCONF="-D GMX_BINARY_SUFFIX=${MPI_SUFFIX}${p} -D GMX_LIBS_SUFFIX=${MPI_SUFFIX}${p}" cd mpich${p} -%cmake %{defopts} %{mpi} $SUFFIXCONF $(test -n "$p" && echo %{double}) .. +%cmake %{defopts} %{mpi} $SUFFIXCONF $(test -n "$p" && echo %{double} || echo %{?single}) .. make VERBOSE=1 %{?_smp_mflags} cd .. done @@ -322,7 +364,7 @@ done for p in '' _d ; do cd serial${p} -%cmake %{defopts} $SUFFIXCONF $(test -n "$p" && echo %{double}) .. +%cmake %{defopts} $SUFFIXCONF $(test -n "$p" && echo %{double} || echo %{?single}) .. make VERBOSE=1 %{?_smp_mflags} cd .. done @@ -440,6 +482,10 @@ done %{_mandir}/man1/gmx*.1* %{_datadir}/%{name} %exclude %{_datadir}/%{name}/template +%exclude %{_datadir}/%{name}/opencl + +%files opencl +%{_datadir}/%{name}/opencl %files doc %{_docdir}/gromacs/manual.pdf @@ -485,6 +531,7 @@ done - don't remove -DNDEBUG from CFLAGS (makes HandlesPermuteModifier test fail randomly) - convert shell variables to rpm macros +- enable OpenCL support (x86 and single precision only) * Tue Sep 22 2015 Dominik 'Rathann' Mierzejewski - 5.1-5 - disable HandlesPermuteModifier test which fails randomly on i686