0

Can I make HTTP requests using OpenCL in C#? I tryed to do this calling system("curl website.com") but only getting an error about system implicit calling.

Anna Boyko
  • 25
  • 5
  • 1
    As always, rather than just saying you're getting "an error" please show the precise code, and the precise error message. (There's no built-in `system` method in C#... you'd normally launch a process using the `System.Diagnostics.Process` class...) – Jon Skeet Mar 28 '22 at 10:44
  • 1
    Although the normal way to make HTTP requests in C# is to use HttpClient... I'm not sure why you want to use curl here. – Jon Skeet Mar 28 '22 at 10:45
  • OpenCl uses C language, so I need to write code for kernel string in C. – Anna Boyko Mar 28 '22 at 14:34
  • So why is C# mentioned in both your title and tag? Currently it's very unclear to me what you're trying to do, or what's happening. – Jon Skeet Mar 28 '22 at 15:25

2 Answers2

1

No, you can't. The OpenCL kernel C/C++ language doesn't support the standard C library - this library is replaced by a custom set of standard functions, geared toward math programming.

The list of functions, which can be used in the kernel language, can be found here.

HEKTO
  • 3,876
  • 2
  • 24
  • 45
0

As others have said, no, it's not possible to do I/O in OpenCL kernels.

Moreover though, it makes no sense to do so; OpenCL is specialised on computationally-intensive massively parallel data processing. Waiting for I/O to complete would entirely defeat the point of it. The usual pattern is:

  1. Collect and prepare your data in the host environment (regular CPU based programming environment; sounds like C# in your case although that's not entirely clear?)
  2. Create OpenCL buffers and fill them with the data
  3. Perform computation in kernels
  4. Put results in buffers
  5. Read back results from the buffers on the host.
  6. Further processing of results, e.g. writing to disk, network, or display on the host.
pmdj
  • 22,018
  • 3
  • 52
  • 103