From a9d7183cd45cb1496d6091e027160ae4bbaf9b72 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - ASCEE" Date: Sun, 23 May 2021 10:19:30 -0700 Subject: [PATCH] Added lasp_nprocs --- lasp/c/lasp_nprocs.c | 18 ++++++++++++++++++ lasp/c/lasp_nprocs.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 lasp/c/lasp_nprocs.c create mode 100644 lasp/c/lasp_nprocs.h 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