Results 1 to 2 of 2

Thread: Can beginners post here? Trying to learn some OpenCL

  1. #1
    Newbie
    Join Date
    Dec 2018
    Posts
    1

    Can beginners post here? Trying to learn some OpenCL

    Is this an appropriate place for C/C++ programmers to ask very basic, beginner questions while referring to their OpenCL reference materials and books?

    I'm stuck. The books seem to provide increasingly obscure examples I can't understand, or graphics examples, which I have no interest in.

    Specifically, I'm looking for reference materials and simple examples that will, I hope, help me to achieve specific goals, one of which is to implement sha256, ripemd160 and maybe other hashing kernels, where I can just input a "password" and verify the hash result output is correct.

    I am not sure, for example, how to specify parameters for such a kernel:

    Code :
    __kernel sha256(unsigned char *in_password, size_t size, unsigned char/uint8_t[32] out_hash)
    {
       // And whether I would have any problems with constant globals, like k[0..63] as described in the pseudocode on Wikipedia
       // And block size, could be an issue with arbitrary size input like char array?  Harder to work with?
    }

    I've looked at many kernels, most I can find in "Bitcoin key cracking" and similar programs, cyrpto-currency miners, etc., but I don't understand them usually because they are mixed up with other routines for their specific purposes. I have looked at hashcat kernels, but I suppose they are too advanced. I can't see how I would call them from a simple driver program, and ensure alignment of data, things like that.

    I'm really in need of a general OpenCL guide so I can get my OpenCL mojo on, understand blocks, threads, devices, memory, alignment, etc., the basics of OpenCL. From there, I would try to implement what I find interesting just for the sake of learning, and writing some code for no particular purpose, just pleasure. One is hash routines, there are others; for example like a "DES ECB mode key cracker" I implemented for multiple CPU systems which finds a single DES key (in a 64-bit search space) across e.g. 32 to 64 CPUs. Translating that into OpenCL would be fun.

    Thank you.

  2. #2
    Junior Member
    Join Date
    May 2017
    Posts
    14
    Quote Originally Posted by accelerator23 View Post
    Is this an appropriate place for C/C++ programmers to ask very basic, beginner questions while referring to their OpenCL reference materials and books?
    Yes, of course!

    Quote Originally Posted by accelerator23 View Post
    I am not sure, for example, how to specify parameters for such a kernel:

    Code :
    __kernel sha256(unsigned char *in_password, size_t size, unsigned char/uint8_t[32] out_hash)
    {
       // And whether I would have any problems with constant globals, like k[0..63] as described in the pseudocode on Wikipedia
       // And block size, could be an issue with arbitrary size input like char array?  Harder to work with?
    }
    This could work, but when you pass pointers to your OpenCL kernel you need to specify which address space they point to. Pointers can point to the "global", "local", "constant", or "private" address space. The different address spaces control visibility and may have different performance characteristics. For more information, see:

    https://www.khronos.org/registry/Ope...ace-qualifiers

    For your usage, you probably want to point to the global address space, or perhaps the constant address space for things like your constant globals.

    Good luck, hope this helps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean