• bitcoinBitcoin(BTC)$77,137.00-2.98%
  • ethereumEthereum(ETH)$2,434.02-2.94%
  • tetherTether(USDT)$1.00-0.01%
  • binancecoinBNB(BNB)$711.56-5.16%
  • rippleXRP(XRP)$1.37-4.77%
  • usd-coinUSDC(USDC)$1.00-0.02%
  • solanaSolana(SOL)$99.89-4.47%
  • tronTRON(TRX)$0.3392540.15%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.03-0.83%
  • zcashZcash(ZEC)$1,214.55-3.87%
  • HyperliquidHyperliquid(HYPE)$81.75-6.03%
  • dogecoinDogecoin(DOGE)$0.084474-7.33%
  • RainRain(RAIN)$0.015964-2.55%
  • USDSUSDS(USDS)$1.00-0.02%
  • moneroMonero(XMR)$503.811.11%
  • whitebitWhiteBIT Coin(WBT)$79.70-3.01%
  • chainlinkChainlink(LINK)$11.71-4.01%
  • leo-tokenLEO Token(LEO)$9.230.25%
  • cardanoCardano(ADA)$0.210762-4.63%
  • stellarStellar(XLM)$0.178008-5.87%
  • bitcoin-cashBitcoin Cash(BCH)$242.21-6.65%
  • daiDai(DAI)$1.00-0.02%
  • Ethena USDeEthena USDe(USDE)$1.00-0.02%
  • USD1USD1(USD1)$1.000.00%
  • litecoinLitecoin(LTC)$52.10-3.62%
  • CantonCanton(CC)$0.100382-5.58%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.36-2.72%
  • uniswapUniswap(UNI)$5.97-11.14%
  • Global DollarGlobal Dollar(USDG)$1.000.01%
  • avalanche-2Avalanche(AVAX)$7.64-4.22%
  • hedera-hashgraphHedera(HBAR)$0.075262-4.31%
  • nearNEAR Protocol(NEAR)$2.40-7.53%
  • suiSui(SUI)$0.76-7.53%
  • shiba-inuShiba Inu(SHIB)$0.000005-6.41%
  • paypal-usdPayPal USD(PYUSD)$1.000.00%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • crypto-com-chainCronos(CRO)$0.056299-6.54%
  • MemeCoreMemeCore(M)$1.200.85%
  • tether-goldTether Gold(XAUT)$4,329.93-1.35%
  • Circle USYCCircle USYC(USYC)$1.140.01%
  • Ripple USDRipple USD(RLUSD)$1.000.00%
  • BittensorBittensor(TAO)$247.17-7.41%
  • okbOKB(OKB)$111.13-3.01%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.14-0.12%
  • mantleMantle(MNT)$0.59-8.22%
  • AsterAster(ASTER)$0.70-6.44%
  • aaveAave(AAVE)$122.27-5.42%
  • pax-goldPAX Gold(PAXG)$4,330.22-1.42%
  • polkadotPolkadot(DOT)$1.09-7.34%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.0559980.29%
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

IBM and NASA Open-Source Lunar Foundation Model With SomBench Dataset – Unite.AI

NASA And IBM Made An AI Model For Exploring The Moon

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

IBM and NASA Open-Source Lunar Foundation Model With SomBench Dataset – Unite.AI
AI & Technology

IBM and NASA Open-Source Lunar Foundation Model With SomBench Dataset – Unite.AI

September 10, 2026
NASA And IBM Made An AI Model For Exploring The Moon
AI & Technology

NASA And IBM Made An AI Model For Exploring The Moon

September 10, 2026
Fujitsu Signs New Palantir AIP Agreement, Becomes Global FDE Partner – Unite.AI
AI & Technology

Fujitsu Signs New Palantir AIP Agreement, Becomes Global FDE Partner – Unite.AI

September 10, 2026
AppleCare One Now Has A  Tier Per Month For Families
AI & Technology

AppleCare One Now Has A $50 Tier Per Month For Families

September 10, 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
Why Did The Market Rally Today – What Changed?!?

Why Did The Market Rally Today – What Changed?!?

September 5, 2026
Firefighters battle Spain’s biggest wildfire of 2026

Firefighters battle Spain’s biggest wildfire of 2026

September 7, 2026
Chinese national rescued from Nepal tunnel 10 days after flash flood – Reuters

Chinese national rescued from Nepal tunnel 10 days after flash flood – Reuters

September 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!