Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

vslloadstreamf and vslsavestreamf

may_ka
Beginner
845 Views

Hi,

I am wondering whether a random number stream created with vslloadstreamf should continue at the state where the previous stream was dumped via vslsavestreamf? I tried the following

  • create a stream via vslnewstream
  • run a loop of 10 filling a matrix with 11 columns with random numbers, but only columns 1-10
  • save the stream state at round 9 via vslsavestreamf
  • destroy the stream after round 10
  • create a new stream via vslloadstreamf
  • fill the 11 column of the above matrix with random numbers from that stream

My expectation was the entries in column 10 and 11 of the matrix are exactly equal. This was not the case. I understood the phrase "saving the stream state" in the mkl manual such that columns 10 and 11 should be equal. Did I miss-understand the implications of "saving the stream state", or did I do anything wrong?

Thanks

0 Kudos
7 Replies
mecej4
Honored Contributor III
829 Views

I took the example vslstream2file.f that is included in the MKL distribution, and modified it to fit your description, using a real matrix with 10 rows and 11 columns. I found that columns 10 and 11 were identical.

Perhaps the devil is in the details. Please provide your test code and name the compiler version and options.

0 Kudos
may_ka
Beginner
792 Views

hi

thanks for looking into this

here is the code:

include "mkl_vsl.f90"
program test
  use, intrinsic :: iso_fortran_env, only: int64, real64
  use mkl_vsl
  use mkl_vsl_type
  implicit none
  type(vsl_stream_state), allocatable :: stream
  integer :: seed=12345, err=0, i, n=10
  real(real64), allocatable :: ran(:,:)
  character(:), allocatable :: file
  file="backup"//achar(0)
  allocate(stream)
  err=vslnewstream(stream,vsl_brng_mcg59,seed)
  allocate(ran(n,6),source=0._real64)
  do i=1,5
    err=vdrnguniform(&
      &method=vsl_rng_method_uniform_std_accurate,&
      &stream=stream,&
      &n=n,&
      &r=ran(:,i),&
      &a=0._real64,&
      &b=1._real64&
      &)
    if(err/=0) stop("e_1")
    if(i==4) then
      err=vslsavestreamf(stream,file);if(err/=0) stop("e_2")
    end if
  end do
  do i=1,n
    write(54,"(*(g0:"",""))") ran(i,:)
  end do
  err=vsldeletestream(stream);if(err/=0) stop("e_3")
  deallocate(stream);allocate(stream)
  err=vslloadstreamf(stream,file);if(err/=0) stop("e_4")
  err=vdrnguniform(&
      &method=vsl_rng_method_uniform_std_accurate,&
      &stream=stream,&
      &n=n,&
      &r=ran(:,6),&
      &a=0._real64,&
      &b=1._real64&
      &)
  if(err/=0) stop("e_5")
  write(*,*) maxval(abs(ran(:,5)-ran(:,6)))
  do i=1,n
    write(55,"(*(g0:"",""))") ran(i,:)
  end do
end program test

 

values in column 5 and 6 are:

.5473213773260636,.5473213773260636
.2389786232270872,.5604556829432085
.8935433105367024,.8387970600185911E-02
.3583476676634463,.3696792567022830
.5604556829432085,.8048426450699457E-01
.2037354232470519,.2041821355220092
.6115156080720576,.2845506451480754
.8546388208725005,.6017603680188723
.8387970600185911E-02,.6126414139055257
.9922226494797135,.7575543283586325

 

Compiler and mkl versions were 19.05 and 19.1.1. Operation system is linux.

thanks

0 Kudos
mecej4
Honored Contributor III
784 Views

I built and ran your test program on Windows 10 x64 using (i) IFort 16.0.8, (ii) IFort 19.0.5 , and (iii) IFort 19.1.2.

Between runs, I deleted the .mod, .obj and fort.5n files.

In all three runs, the program printed out " 0.000000000000000E+000" and the fifth and sixth columns of output file fort.55 were identical.

I do not have a Linux system with IFort on it as of now. Perhaps someone else with such a system can repeat the test, as it only takes a minute.

0 Kudos
Gennady_F_Intel
Moderator
775 Views

I see the different outpupts when the different code path has been applied:

>set MKL_CBWR=SSE2

>1.exe

Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications         

  0.000000000000000E+000

>set MKL_CBWR=AVX2

>1.exe

Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications         

 0.885155339936517

We will investigate the cause of the problem and keep the thread updated.

 

 

0 Kudos
Gennady_F_Intel
Moderator
699 Views

The fix of the problem has been released as a part of oneMKL v.2021.1. Intel MKL 2021 package is now ready for download.

0 Kudos
MRajesh_intel
Moderator
584 Views

Hi,


Can you please let us know if your issue has been resolved or not?


Regards

Rajesh.


0 Kudos
MRajesh_intel
Moderator
572 Views

Hi,


Since we didn't hear back from you, we are closing this thread for now. If you require any additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


Have a Good day.


Regards

Rajesh


0 Kudos
Reply