MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / UnifiedVectorWrapper

Method UnifiedVectorWrapper

ngscuda/unifiedvector.cpp:363–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361 }
362
363 UnifiedVectorWrapper :: UnifiedVectorWrapper(const BaseVector & vec_, optional<IntRange> opt_range)
364 : vec(vec_)
365 {
366 IntRange range = {0, vec.Size()};
367 if(opt_range)
368 range = *opt_range;
369 this->size = range.Size();
370
371 auto uptr = dynamic_cast<const UnifiedVector*>(&vec_);
372 if(uptr)
373 {
374 host_data = uptr->HostData() + range.First();
375 dev_data = uptr->DevData() + range.First();
376 uptr->UpdateDevice();
377 uptr->InvalidateHost();
378 initial_host_uptodate = uptr->IsHostUptodate();
379 initial_dev_uptodate = uptr->IsDevUptodate();
380 }
381 else
382 {
383 auto err = cudaMalloc((void**)&dev_data, size*sizeof(double));
384 if (err != 0)
385 throw Exception("UnifiedVector allocation error, ec="+ToString(err));
386 initial_host_uptodate = true;
387 initial_dev_uptodate = false;
388 host_data = vec.FVDouble().Data() + range.First();
389 }
390 host_uptodate = initial_host_uptodate;
391 dev_uptodate = initial_dev_uptodate;
392 }
393
394 UnifiedVectorWrapper :: ~UnifiedVectorWrapper()
395 {

Callers

nothing calls this directly

Calls 10

ToStringFunction · 0.85
HostDataMethod · 0.80
InvalidateHostMethod · 0.80
IsHostUptodateMethod · 0.80
IsDevUptodateMethod · 0.80
FVDoubleMethod · 0.80
SizeMethod · 0.45
FirstMethod · 0.45
DevDataMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected