• bitcoinBitcoin(BTC)$60,804.00-0.26%
  • ethereumEthereum(ETH)$1,566.56-0.88%
  • tetherTether(USDT)$1.00-0.01%
  • binancecoinBNB(BNB)$574.550.94%
  • usd-coinUSDC(USDC)$1.000.01%
  • rippleXRP(XRP)$1.09-0.01%
  • solanaSolana(SOL)$62.11-1.77%
  • tronTRON(TRX)$0.3238961.26%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.030.46%
  • dogecoinDogecoin(DOGE)$0.0818040.96%
  • HyperliquidHyperliquid(HYPE)$56.66-4.26%
  • USDSUSDS(USDS)$1.00-0.02%
  • leo-tokenLEO Token(LEO)$9.45-1.38%
  • RainRain(RAIN)$0.012894-0.63%
  • stellarStellar(XLM)$0.2131395.60%
  • CantonCanton(CC)$0.16427810.20%
  • zcashZcash(ZEC)$362.64-5.91%
  • cardanoCardano(ADA)$0.1570010.60%
  • moneroMonero(XMR)$295.52-3.99%
  • chainlinkChainlink(LINK)$7.390.87%
  • whitebitWhiteBIT Coin(WBT)$43.33-0.16%
  • USD1USD1(USD1)$1.000.08%
  • Ethena USDeEthena USDe(USDE)$1.00-0.02%
  • the-open-networkToncoin(TON)$1.638.42%
  • bitcoin-cashBitcoin Cash(BCH)$217.404.25%
  • daiDai(DAI)$1.00-0.03%
  • LABLAB(LAB)$13.4537.96%
  • MemeCoreMemeCore(M)$3.004.42%
  • hedera-hashgraphHedera(HBAR)$0.079748-0.52%
  • litecoinLitecoin(LTC)$41.25-4.12%
  • suiSui(SUI)$0.723.05%
  • avalanche-2Avalanche(AVAX)$6.66-0.11%
  • paypal-usdPayPal USD(PYUSD)$1.000.06%
  • Circle USYCCircle USYC(USYC)$1.130.00%
  • shiba-inuShiba Inu(SHIB)$0.0000050.71%
  • tether-goldTether Gold(XAUT)$4,288.25-0.28%
  • crypto-com-chainCronos(CRO)$0.0582481.01%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • nearNEAR Protocol(NEAR)$1.86-5.13%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.130.92%
  • pax-goldPAX Gold(PAXG)$4,296.67-0.53%
  • BittensorBittensor(TAO)$193.50-0.17%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.055862-1.06%
  • mantleMantle(MNT)$0.51-0.47%
  • Ripple USDRipple USD(RLUSD)$1.000.02%
  • AsterAster(ASTER)$0.621.19%
  • polkadotPolkadot(DOT)$0.940.38%
  • HTX DAOHTX DAO(HTX)$0.0000020.83%
  • OndoOndo(ONDO)$0.324368-5.23%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

A Coding Implementation to Master GPU Computing with CuPy, Custom CUDA Kernels, Streams, Sparse Matrices, and Profiling

May 14, 2026
in AI & Technology
Reading Time: 1 min read
A A
A Coding Implementation to Master GPU Computing with CuPy, Custom CUDA Kernels, Streams, Sparse Matrices, and Profiling
ShareShareShareShareShare

YOU MAY ALSO LIKE

AI Has Become Major Capital Formation Cycle, Says Altimeter

Anthropic’s Ethicist on Whether AI Can Become Conscious

header("6. RAW CUDA KERNEL — MANDELBROT")
mandel = cp.RawKernel(r'''
extern "C" __global__
void mandel(float xmin, float xmax, float ymin, float ymax,
           int W, int H, int max_iter, int* out) {
   int ix = blockDim.x * blockIdx.x + threadIdx.x;
   int iy = blockDim.y * blockIdx.y + threadIdx.y;
   if (ix >= W || iy >= H) return;
   float cx = xmin + (xmax - xmin) * ix / (W - 1);
   float cy = ymin + (ymax - ymin) * iy / (H - 1);
   float zx = 0.f, zy = 0.f;
   int it = 0;
   while (zx*zx + zy*zy < 4.f && it < max_iter) {
       float t = zx*zx - zy*zy + cx;
       zy = 2.f*zx*zy + cy;
       zx = t; ++it;
   }
   out[iy*W + ix] = it;
}
''', 'mandel')
W, H, ITER = 1024, 1024, 400
img = cp.zeros((H, W), dtype=cp.int32)
threads = (16, 16)
blocks = ((W + 15)//16, (H + 15)//16)
mandel(blocks, threads,
      (cp.float32(-2.0), cp.float32(1.0),
       cp.float32(-1.5), cp.float32(1.5),
       W, H, ITER, img))
cp.cuda.Stream.null.synchronize()
print(f"Mandelbrot done. max iter reached={int(img.max())}")
plt.figure(figsize=(6,6))
plt.imshow(cp.asnumpy(cp.log1p(img)), cmap='twilight_shifted', extent=[-2,1,-1.5,1.5])
plt.title("Mandelbrot set — computed with a CuPy RawKernel")
plt.axis('off'); plt.show()
header("7. CUDA STREAMS")
s1, s2 = cp.cuda.Stream(non_blocking=True), cp.cuda.Stream(non_blocking=True)
with s1:
   a1 = cp.random.rand(2000, 2000, dtype=cp.float32)
   b1 = cp.random.rand(2000, 2000, dtype=cp.float32)
   c1 = a1 @ b1
with s2:
   a2 = cp.random.rand(2000, 2000, dtype=cp.float32)
   b2 = cp.random.rand(2000, 2000, dtype=cp.float32)
   c2 = a2 @ b2
s1.synchronize(); s2.synchronize()
print(f"Stream-1 mean={float(c1.mean()):.4f}")
print(f"Stream-2 mean={float(c2.mean()):.4f}")

Credit: Source link

ShareTweetSendSharePin

Related Posts

AI Has Become Major Capital Formation Cycle, Says Altimeter
AI & Technology

AI Has Become Major Capital Formation Cycle, Says Altimeter

June 6, 2026
Anthropic’s Ethicist on Whether AI Can Become Conscious
AI & Technology

Anthropic’s Ethicist on Whether AI Can Become Conscious

June 6, 2026
Anthropic President Amodei on the Future of Claude
AI & Technology

Anthropic President Amodei on the Future of Claude

June 6, 2026
Bloomberg Tech Event Special | Bloomberg Tech 6/04/2026
AI & Technology

Bloomberg Tech Event Special | Bloomberg Tech 6/04/2026

June 6, 2026
Next Post
Preliminary investigation suggests WHCD shooter was targeting Trump admin, Acting AG Blanche says

Preliminary investigation suggests WHCD shooter was targeting Trump admin, Acting AG Blanche says

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
How to prepare yourself or a loved one to truly live a longer life

How to prepare yourself or a loved one to truly live a longer life

May 31, 2026
China and Russia sign agreements strengthening their ties after Xi-Putin meeting

China and Russia sign agreements strengthening their ties after Xi-Putin meeting

June 1, 2026
Meet the Press Full Episode — May 17

Meet the Press Full Episode — May 17

June 5, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!