Resources.java [src/java/m/oms] Revision: 63d064da03658faac5472f372ab39b7a76edecba  Date: Wed Aug 16 16:24:31 MDT 2023
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package m.oms;

import csip.Config;
import csip.api.server.PayloadParameter;
import csip.api.server.ServiceException;

/**
 *
 * @author holm,od
 */
public abstract class Resources {

    public static final String DDM = "row";

    static final String MPI_THREADS = "mpi.cores";

    public static final String LOCATION_MNT_DATA
            = Config.getString("oms.data.path", "/mnt/csip-oms");

    /**
     * get the # threads for MPI calls.
     *
     * @param parameter
     * @return
     * @throws ServiceException
     */
    public static int mpiThreads(PayloadParameter parameter) throws ServiceException {
        int threads = Runtime.getRuntime().availableProcessors() / 2;
        threads = threads + (threads / 2);      // using 75% of physical cores
        threads = Config.getInt(MPI_THREADS, threads); // config
        if (parameter != null) {
            threads = parameter.getInt(MPI_THREADS, threads);  // payload
        }
        return threads;
    }
}