-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding OpenRNG Backend #2871
Adding OpenRNG Backend #2871
Conversation
/intelci: run |
@Alexandr-Solovev, any feedbacks on this? |
/intelci: run |
To build using openrng backend follow these steps .ci/scripts/build.sh --compiler gnu --optimizations sve \ --target onedal_c --backend-config ref --plat lnxarm --use-openrng yes .ci/scripts/build.sh --compiler gnu --optimizations sve \ --target daal --backend-config ref --plat lnxarm --use-openrng yes With this PR, openRNG backend becomes available for builds on arm machine with ref backend using gnu compiler. (For the other kinds of ref builds, support can be added in the future) The script `.ci/env/openrng.sh` builds openrng at `__deps/openrng`. For more control over the build process, this script can be run before running the make command. While building using make, the variable `RNG_BACKEND` should be set to `openrng` for the build to use openRNG backend. If openRNG is installed in a directory other than `./__deps/openrng`, the environment variable `OPENRNGROOT` can be set before using the make command to specify the openRNG build directory. Signed-off-by: Dhanus M Lal <Dhanus.MLal@fujitsu.com>
Signed-off-by: Dhanus M Lal <Dhanus.MLal@fujitsu.com>
182a11a
to
f2a380d
Compare
{ | ||
services::Status s = allocSeeds(n); | ||
if (s) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just directly reporting an error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how to report an error in the constructor. I could throw an exception, but the calling functions may not have mechanisms to handle them. Also, this is exactly how the MKL backend handles it (in service_rng_mkl.h). In fact service_rng_openrng.h is a copy of service_rng_mkl.h, except for some minor changes.
services::Status s = allocSeeds(_seedSize); | ||
if (s) | ||
{ | ||
for (size_t i = 0; i < _seedSize; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a matter of preferences but I would suggest to use correctly typed constants i.e. 0ul
instead of an implicit conversion from 0 wherever it is posssible
/intelci: run |
2 similar comments
/intelci: run |
/intelci: run |
Hi @DhanusML thanks for putting this together, in order to run our internal validation the fork name must be oneDAL or daal. Would you mind changing yours from oneDAL-dhanus to just oneDAL? |
Done |
/intelci: run |
Please rebase your branch as well |
/intelci: run |
Changes look reasonable to me - but there is no validation from what I can tell. Perhaps it would make sense to add this flag to one of the ARM CI checks? |
@@ -0,0 +1,393 @@ | |||
/* file: service_rng_openrng.h.h */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service_rng_openrng.h
int nb = len / 2; | ||
int nn = (int)n; | ||
int * rr = (int *)r; | ||
__DAAL_VSLFN_CALL_NR_WHILE(, viRngUniform, (method, stream, nn, rr, na, nb), errcode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use DAAL macros in this file? Are you sure that it will be opened and work as expected? Can it be replaced with the direct call of openrng functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be replaced with direct calls to openrng functions. It works as expected using daal macros (from service_stat_rng_ref.h) but, I will change them to direct function calls for the sake of readability.
int nb = len / 2; | ||
int nn = (int)n; | ||
int * rr = (int *)r; | ||
__DAAL_VSLFN_CALL_NR_WHILE(, viRngUniform, (method, stream, nn, rr, na, nb), errcode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the method and n be casted to openrng_int_t?
.ci/scripts/build.sh
Outdated
@@ -34,6 +34,7 @@ show_help() { | |||
--plat:The platform to build for. This is passed to the oneDAL top level Makefile | |||
--blas-dir:The BLAS installation directory to use to build oneDAL with in the case that the backend is given as `ref`. If the installation directory does not exist, attempts to build this from source | |||
--tbb-dir:The TBB installation directory to use to build oneDAL with in the case that the backend is given as `ref`. If the installation directory does not exist, attempts to build this from source | |||
--use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this with the `ref` backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this with the `ref` backend. | |
--use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this only with the `ref` backend. |
makefile
Outdated
ifeq ($(RNG_BACKEND), openrng) | ||
RNG_OPENRNG := yes | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RNG_BACKEND variable should be one of mkl
, ref
and openrng
with default value dependent on platform type.
Signed-off-by: Dhanus M Lal <Dhanus.MLal@fujitsu.com>
setting RNG_BACKEND variable based on the backend config in makefile. Signed-off-by: Dhanus M Lal <Dhanus.MLal@fujitsu.com>
/intelci: run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
OpenRNG is an open-source Random Number Generator library developed at Arm. OpenRNG includes the interface to the random number generation part of the Vector Statistics Library (VSL) developed by Intel(R) and shipped for x86 processors as part of oneMKL. This PR adds an option to use OpenRNG as the RNG backend for oneDAL.
To build using OpenRNG backend follow these steps
With this PR, OpenRNG backend becomes available for builds on arm machine with ref backend using gnu compiler. (For the other kinds of ref builds, support can be added in the future)
The script
.ci/env/openrng.sh
builds openrng at__deps/openrng
. For more control over the build process, this script can be run before running the make command. While building using make, the variableRNG_BACKEND
should be set toopenrng
for the build to use OpenRNG backend.If openRNG is installed in a directory other than
./__deps/openrng
, the environment variableOPENRNGROOT
can be set before using the make command to specify the openRNG build directory.