Skip to content
Discussion options

You must be logged in to vote

Well, to exclude the time of device-to-host copy, I tried:

import cupy as cp
from cupyx.profiler import benchmark

h, w = 2048, 4096
fractal = cp.empty((h, w), dtype=cp.int32)

cupy_custom_kernel = cp.RawKernel(r'''
#include <cupy/complex.cuh>

extern "C" __global__
void cupy_custom_kernel(int height, int width, int* fractal) {
    int x = blockIdx.x * blockDim.x + threadIdx.x;
    int y = blockIdx.y * blockDim.y + threadIdx.y;

    complex<float> j(0.0, 1.0);
    complex<float> z, c;
    z = c = complex<float>(-1.5 + y*1.0/(height + 1)) - j + complex<float>(x*1.5)*j/complex<float>(width + 1);

    fractal[y + x * width] = 20;
    for (int i = 0;  i < 20;  i++) {
        z = z * z + c;

Replies: 14 comments 42 replies

Comment options

You must be logged in to vote
1 reply
@jpivarski
Comment options

Comment options

You must be logged in to vote
1 reply
@jpivarski
Comment options

Comment options

You must be logged in to vote
4 replies
@jpivarski
Comment options

@YouJiacheng
Comment options

@jpivarski
Comment options

@YouJiacheng
Comment options

Comment options

You must be logged in to vote
1 reply
@jpivarski
Comment options

Comment options

You must be logged in to vote
4 replies
@YouJiacheng
Comment options

@jpivarski
Comment options

@YouJiacheng
Comment options

@YouJiacheng
Comment options

Comment options

You must be logged in to vote
2 replies
@YouJiacheng
Comment options

@jobs-git
Comment options

Answer selected by jpivarski
Comment options

You must be logged in to vote
6 replies
@YouJiacheng
Comment options

@jpivarski
Comment options

@YouJiacheng
Comment options

@YouJiacheng
Comment options

@jpivarski
Comment options

Comment options

You must be logged in to vote
5 replies
@YouJiacheng
Comment options

@YouJiacheng
Comment options

@jpivarski
Comment options

@YouJiacheng
Comment options

@YouJiacheng
Comment options

Comment options

You must be logged in to vote
3 replies
@jpivarski
Comment options

@YouJiacheng
Comment options

@YouJiacheng
Comment options

Comment options

You must be logged in to vote
3 replies
@chriselrod
Comment options

@Moelf
Comment options

@YouJiacheng
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@vchuravy
Comment options

@Moelf
Comment options

@Sixzero
Comment options

Comment options

You must be logged in to vote
8 replies
@YouJiacheng
Comment options

@j-bac
Comment options

@Moelf
Comment options

@j-bac
Comment options

@cchapmanbird
Comment options

Comment options

You must be logged in to vote
1 reply
@Moelf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet