Advertisement
Wow_Rasl

Untitled

May 25th, 2022
565
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "cuda_runtime.h"
  2. #include "device_launch_parameters.h"
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. __global__ void mykernel(void) {
  8. }
  9. __global__ void addKernel(int* c, const int* a, const int* b) {
  10.     int i = threadIdx.x;
  11.     c[i] = a[i] + b[i];
  12. }
  13. float f(float x) {
  14.     return 0,25 * x * x;
  15. }
  16. void parallel_monte_carlo_integrate(int R, float* result) {
  17.     srand(time(NULL));
  18.     float w = 1 / R;
  19.     int i = 0;
  20.     int x = (rand() / RAND_MAX + i * w) / R;
  21.     int y = rand() / RAND_MAX;
  22.     printf("x=%lf", x);
  23.  
  24. }
  25. int main(void) {
  26.     parallel_monte_carlo_integrate(1, 0);
  27.     return 0;
  28.  
Advertisement
RAW Paste Data Copied
Advertisement