+ rank, gpu_opt->n_dev_compatible).c_str());
+
+ if (gpu_opt->n_dev_compatible == 0)
+ {
+ char host[255];
+
+ gmx_gethostname(host, 255);
+ gmx_fatal(FARGS, "A GPU was requested on host %s, but no compatible GPUs were detected. All nodes with PP ranks need to have GPUs. If you intended to use GPU acceleration in a parallel run, you can either avoid using the nodes that don't have GPUs or place PME ranks on these nodes.", host);
+ }
+
+ int nshare;
+
+ nshare = 1;
+ if (nrank > gpu_opt->n_dev_compatible)
+ {
+ if (nrank % gpu_opt->n_dev_compatible == 0)
+ {
+ nshare = nrank/gpu_opt->n_dev_compatible;
+ }
+ else
+ {
+ if (rank == 0)
+ {
+ gmx_fatal(FARGS, "The number of MPI ranks (%d) in a physical node is not a multiple of the number of GPUs (%d). Select a different number of MPI ranks or use the -gpu_id option to manually specify the GPU to be used.",
+ nrank, gpu_opt->n_dev_compatible);
+ }
+
+#ifdef GMX_MPI
+ /* We use a global barrier to prevent ranks from continuing with
+ * an invalid setup.
+ */
+ MPI_Barrier(MPI_COMM_WORLD);
+#endif
+ }
+ }