sf.c (3ac29d2da70e07e8d78ef4a20ed797efa8f6915e) sf.c (d0295fc027abbea29f13fa82c19cf92da8e9ba99)
1#include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/
2#include <petsc/private/hashseti.h>
3#include <petscctable.h>
4
5#if defined(PETSC_HAVE_CUDA)
6 #include <cuda_runtime.h>
7#endif
8

--- 1392 unchanged lines hidden (view full) ---

1401. rootdata - buffer to broadcast
1402- op - operation to use for reduction
1403
1404 Output Arguments:
1405. leafdata - buffer to be reduced with values from each leaf's respective root
1406
1407 Level: intermediate
1408
1#include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/
2#include <petsc/private/hashseti.h>
3#include <petscctable.h>
4
5#if defined(PETSC_HAVE_CUDA)
6 #include <cuda_runtime.h>
7#endif
8

--- 1392 unchanged lines hidden (view full) ---

1401. rootdata - buffer to broadcast
1402- op - operation to use for reduction
1403
1404 Output Arguments:
1405. leafdata - buffer to be reduced with values from each leaf's respective root
1406
1407 Level: intermediate
1408
1409.seealso: PetscSFBcastAndOpEnd(), PetscSFBcastBegin(), PetscSFBcastEnd()
1409 Notes:
1410 When petsc is configured with device support, it will use its own mechanism to figure out whether the given data pointers
1411 are host pointers or device pointers, which may incur a noticable cost. If you already knew the info, you should
1412 use PetscSFBcastAndOpWithMemTypeBegin() instead.
1413.seealso: PetscSFBcastAndOpEnd(), PetscSFBcastBegin(), PetscSFBcastEnd(), PetscSFBcastAndOpWithMemTypeBegin()
1410@*/
1411PetscErrorCode PetscSFBcastAndOpBegin(PetscSF sf,MPI_Datatype unit,const void *rootdata,void *leafdata,MPI_Op op)
1412{
1413 PetscErrorCode ierr;
1414 PetscMemType rootmtype,leafmtype;
1415
1416 PetscFunctionBegin;
1417 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1418 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1419 ierr = PetscLogEventBegin(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1420 ierr = PetscGetMemType(rootdata,&rootmtype);CHKERRQ(ierr);
1421 ierr = PetscGetMemType(leafdata,&leafmtype);CHKERRQ(ierr);
1422 ierr = (*sf->ops->BcastAndOpBegin)(sf,unit,rootmtype,rootdata,leafmtype,leafdata,op);CHKERRQ(ierr);
1423 ierr = PetscLogEventEnd(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1424 PetscFunctionReturn(0);
1425}
1426
1427/*@C
1414@*/
1415PetscErrorCode PetscSFBcastAndOpBegin(PetscSF sf,MPI_Datatype unit,const void *rootdata,void *leafdata,MPI_Op op)
1416{
1417 PetscErrorCode ierr;
1418 PetscMemType rootmtype,leafmtype;
1419
1420 PetscFunctionBegin;
1421 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1422 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1423 ierr = PetscLogEventBegin(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1424 ierr = PetscGetMemType(rootdata,&rootmtype);CHKERRQ(ierr);
1425 ierr = PetscGetMemType(leafdata,&leafmtype);CHKERRQ(ierr);
1426 ierr = (*sf->ops->BcastAndOpBegin)(sf,unit,rootmtype,rootdata,leafmtype,leafdata,op);CHKERRQ(ierr);
1427 ierr = PetscLogEventEnd(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1428 PetscFunctionReturn(0);
1429}
1430
1431/*@C
1432 PetscSFBcastAndOpWithMemTypeBegin - begin pointwise broadcast with root value being reduced to leaf value with explicit memory types, to be concluded with call to PetscSFBcastAndOpEnd()
1433
1434 Collective on PetscSF
1435
1436 Input Arguments:
1437+ sf - star forest on which to communicate
1438. unit - data type associated with each node
1439. rootmtype - memory type of rootdata
1440. rootdata - buffer to broadcast
1441. leafmtype - memory type of leafdata
1442- op - operation to use for reduction
1443
1444 Output Arguments:
1445. leafdata - buffer to be reduced with values from each leaf's respective root
1446
1447 Level: intermediate
1448
1449.seealso: PetscSFBcastAndOpEnd(), PetscSFBcastBegin(), PetscSFBcastEnd(),PetscSFBcastAndOpBegin()
1450@*/
1451PetscErrorCode PetscSFBcastAndOpWithMemTypeBegin(PetscSF sf,MPI_Datatype unit,PetscMemType rootmtype,const void *rootdata,PetscMemType leafmtype,void *leafdata,MPI_Op op)
1452{
1453 PetscErrorCode ierr;
1454
1455 PetscFunctionBegin;
1456 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1457 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1458 ierr = PetscLogEventBegin(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1459 ierr = (*sf->ops->BcastAndOpBegin)(sf,unit,rootmtype,rootdata,leafmtype,leafdata,op);CHKERRQ(ierr);
1460 ierr = PetscLogEventEnd(PETSCSF_BcastAndOpBegin,sf,0,0,0);CHKERRQ(ierr);
1461 PetscFunctionReturn(0);
1462}
1463
1464/*@C
1428 PetscSFBcastAndOpEnd - end a broadcast & reduce operation started with PetscSFBcastAndOpBegin()
1429
1430 Collective
1431
1432 Input Arguments:
1433+ sf - star forest
1434. unit - data type
1435. rootdata - buffer to broadcast

--- 29 unchanged lines hidden (view full) ---

1465. leafdata - values to reduce
1466- op - reduction operation
1467
1468 Output Arguments:
1469. rootdata - result of reduction of values from all leaves of each root
1470
1471 Level: intermediate
1472
1465 PetscSFBcastAndOpEnd - end a broadcast & reduce operation started with PetscSFBcastAndOpBegin()
1466
1467 Collective
1468
1469 Input Arguments:
1470+ sf - star forest
1471. unit - data type
1472. rootdata - buffer to broadcast

--- 29 unchanged lines hidden (view full) ---

1502. leafdata - values to reduce
1503- op - reduction operation
1504
1505 Output Arguments:
1506. rootdata - result of reduction of values from all leaves of each root
1507
1508 Level: intermediate
1509
1473.seealso: PetscSFBcastBegin()
1510 Notes:
1511 When petsc is configured with device support, it will use its own mechanism to figure out whether the given data pointers
1512 are host pointers or device pointers, which may incur a noticable cost. If you already knew the info, you should
1513 use PetscSFReduceWithMemTypeBegin() instead.
1514
1515.seealso: PetscSFBcastBegin(), PetscSFReduceWithMemTypeBegin()
1474@*/
1475PetscErrorCode PetscSFReduceBegin(PetscSF sf,MPI_Datatype unit,const void *leafdata,void *rootdata,MPI_Op op)
1476{
1477 PetscErrorCode ierr;
1478 PetscMemType rootmtype,leafmtype;
1479
1480 PetscFunctionBegin;
1481 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1482 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1483 ierr = PetscLogEventBegin(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1484 ierr = PetscGetMemType(rootdata,&rootmtype);CHKERRQ(ierr);
1485 ierr = PetscGetMemType(leafdata,&leafmtype);CHKERRQ(ierr);
1486 ierr = (sf->ops->ReduceBegin)(sf,unit,leafmtype,leafdata,rootmtype,rootdata,op);CHKERRQ(ierr);
1487 ierr = PetscLogEventEnd(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1488 PetscFunctionReturn(0);
1489}
1490
1491/*@C
1516@*/
1517PetscErrorCode PetscSFReduceBegin(PetscSF sf,MPI_Datatype unit,const void *leafdata,void *rootdata,MPI_Op op)
1518{
1519 PetscErrorCode ierr;
1520 PetscMemType rootmtype,leafmtype;
1521
1522 PetscFunctionBegin;
1523 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1524 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1525 ierr = PetscLogEventBegin(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1526 ierr = PetscGetMemType(rootdata,&rootmtype);CHKERRQ(ierr);
1527 ierr = PetscGetMemType(leafdata,&leafmtype);CHKERRQ(ierr);
1528 ierr = (sf->ops->ReduceBegin)(sf,unit,leafmtype,leafdata,rootmtype,rootdata,op);CHKERRQ(ierr);
1529 ierr = PetscLogEventEnd(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1530 PetscFunctionReturn(0);
1531}
1532
1533/*@C
1534 PetscSFReduceWithMemTypeBegin - begin reduction of leafdata into rootdata with explicit memory types, to be completed with call to PetscSFReduceEnd()
1535
1536 Collective
1537
1538 Input Arguments:
1539+ sf - star forest
1540. unit - data type
1541. leafmtype - memory type of leafdata
1542. leafdata - values to reduce
1543. rootmtype - memory type of rootdata
1544- op - reduction operation
1545
1546 Output Arguments:
1547. rootdata - result of reduction of values from all leaves of each root
1548
1549 Level: intermediate
1550
1551.seealso: PetscSFBcastBegin(), PetscSFReduceBegin()
1552@*/
1553PetscErrorCode PetscSFReduceWithMemTypeBegin(PetscSF sf,MPI_Datatype unit,PetscMemType leafmtype,const void *leafdata,PetscMemType rootmtype,void *rootdata,MPI_Op op)
1554{
1555 PetscErrorCode ierr;
1556
1557 PetscFunctionBegin;
1558 PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1);
1559 ierr = PetscSFSetUp(sf);CHKERRQ(ierr);
1560 ierr = PetscLogEventBegin(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1561 ierr = (sf->ops->ReduceBegin)(sf,unit,leafmtype,leafdata,rootmtype,rootdata,op);CHKERRQ(ierr);
1562 ierr = PetscLogEventEnd(PETSCSF_ReduceBegin,sf,0,0,0);CHKERRQ(ierr);
1563 PetscFunctionReturn(0);
1564}
1565
1566/*@C
1492 PetscSFReduceEnd - end a reduction operation started with PetscSFReduceBegin()
1493
1494 Collective
1495
1496 Input Arguments:
1497+ sf - star forest
1498. unit - data type
1499. leafdata - values to reduce

--- 623 unchanged lines hidden ---
1567 PetscSFReduceEnd - end a reduction operation started with PetscSFReduceBegin()
1568
1569 Collective
1570
1571 Input Arguments:
1572+ sf - star forest
1573. unit - data type
1574. leafdata - values to reduce

--- 623 unchanged lines hidden ---