- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi!

I'm new with oneapi and i'm trying to do a simple program for my university project doing a custom version of Pi Montecarlo Estimation.

I'm almost done, but i have troubles creating the random numbers using uniform distribution.

Can someone please help me with this errors that i keep getting?

Leaving the code and logs of errors under this line:

```
#include <sycl/sycl.hpp>
#include <oneapi/mkl/rng.hpp>
using namespace sycl;
static const int N_POINTS = 10;
static const int N_SIM = 10;
int create_points_and_calculate_eq(queue q){
// create basic random number generator object
oneapi::mkl::rng::philox4x32x10 engine(q, 777);
// create distribution object
oneapi::mkl::rng::uniform<double, oneapi::mkl::rng::uniform_method::standard> distr(0.0, 1.0);
// creating vectors to store the points
std::vector<double> sum_squared(N_POINTS);
std::vector<double> x_sim(N_POINTS);
std::vector<double> y_sim(N_POINTS);
// creating Buffers for X/Y
buffer<double> buf_x(x_sim.data(),x_sim.size());
buffer<double> buf_y(y_sim.data(),y_sim.size());
//Generating points
oneapi::mkl::rng::generate(distr, engine, N_POINTS, buf_x);
oneapi::mkl::rng::generate(distr, engine, N_POINTS, buf_y);
//Creating buffer to store the sum of x**2 + y**2
buffer<double> sum_sq(sum_squared.data(),sum_squared.size());
q.submit([&](handler &h){
auto V_x = buf_x.get_access<access::mode::read_write>(h);
auto V_y = buf_y.get_access<access::mode::read_write>(h);
auto X_PLUS_Y_SQ = sum_sq.get_access<access::mode::read_write>(h);
h.parallel_for(range<1>(N_POINTS),[=] (id<1> i){
double sum = V_x[i] * V_x[i] + V_y[i] * V_y[i];
if (sum>1){X_PLUS_Y_SQ[i] = 0;}
else{X_PLUS_Y_SQ[i] = 1;}
});
});
//counts points inside radius=1 circle
int pts_in_circle = 0;
for(int i=0;i<N_POINTS;i++){pts_in_circle+=sum_squared[i];};
return pts_in_circle;
};
int main(){
queue queue_of_simulations;
std::cout << "Device : " << queue_of_simulations.get_device().get_info<info::device::name>() << "\n";
//std::vector<int> results(N_SIM);
int tot_pts_created = N_SIM * N_POINTS;
int pts_in_circle = 0;
for(int i=0;i<N_SIM;i++){pts_in_circle += create_points_and_calculate_eq(queue_of_simulations);};
double pi = 4 * pts_in_circle / tot_pts_created;
std::cout << "Pi Estimated:\t" << pi << std::endl;
}
```

`icpx: error: linker command failed with exit code 1 (use -v to see invocation)`

Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Alessio,

Thanks for reaching out to us.

Could you please try the below command and see if it works on your end?

`icpx -fsycl -qmkl *.cpp`

Please get back to us if you still face any issues.

Regards,

Vidya.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Alessio,

Thanks for reaching out to us.

Could you please try the below command and see if it works on your end?

`icpx -fsycl -qmkl *.cpp`

Please get back to us if you still face any issues.

Regards,

Vidya.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Alechiove ,

As we haven't heard back from you, could you please provide us with an update regarding the issue?

Regards,

Vidya.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yes, Thank you so much!

Solved my problem!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Alessio,

Thanks for accepting the solution.

Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.

Have a Great Day!

Regards,

Vidya.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page