diff --git a/lasp/c/lasp_nprocs.c b/lasp/c/lasp_nprocs.c new file mode 100644 index 0000000..706bec6 --- /dev/null +++ b/lasp/c/lasp_nprocs.c @@ -0,0 +1,18 @@ +#ifdef MS_WIN64 +#include +#else +// Used for obtaining the number of processors +#include +#endif +#include "lasp_nprocs.h" + +us getNumberOfProcs() { +#if MS_WIN64 +// https://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +#else + return get_nprocs(); +#endif +} \ No newline at end of file diff --git a/lasp/c/lasp_nprocs.h b/lasp/c/lasp_nprocs.h new file mode 100644 index 0000000..7ba5458 --- /dev/null +++ b/lasp/c/lasp_nprocs.h @@ -0,0 +1,18 @@ +// lasp_nprocs.h +// +// Author: J.A. de Jong - ASCEE +// +// Description: Implemententation of a function to determine the number +// of processors. +////////////////////////////////////////////////////////////////////// +#pragma once +#ifndef LASP_NPROCS_H +#define LASP_NPROCS_H +#include "lasp_types.h" + +/** + * @return The number of SMP processors + */ +us getNumberOfProcs(); + +#endif // LASP_NPROCS_H \ No newline at end of file