IR_VisItCommunication.scala 2.32 KB
Newer Older
1
2
3
4
5
6
package exastencils.visualization.ir.visit

import scala.collection.mutable.ListBuffer

import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.base.ir._
Richard Angersbach's avatar
Richard Angersbach committed
7
import exastencils.visualization.ir.visit.IR_VisItUtil._
8
9
import exastencils.config._

10
case class IR_VisItBroadcastIntCallback() extends IR_VisItFuturePlainFunction {
11
12
13
  val intValue = IR_FunctionArgument("value", IR_PointerDatatype(IR_IntegerDatatype))
  val sender = IR_FunctionArgument("sender", IR_IntegerDatatype)

14
15
16
  override def generateFct() : IR_PlainFunction = {
    val fctBody = ListBuffer[IR_Statement]()

Richard Angersbach's avatar
Richard Angersbach committed
17
    fctBody += IR_Return(callExtFunction("MPI_Bcast",
18
      intValue.access, IR_IntegerConstant(1), IR_Native("MPI_INT"), sender.access, Knowledge.mpi_defaultCommunicator))
19
20
21
22

    IR_PlainFunction(
      name,
      IR_IntegerDatatype,
23
      ListBuffer(intValue, sender),
24
25
26
27
28
29
30
31
      fctBody
    )

  }

  override def name : String = "visit_broadcast_int_callback"
}

32
case class IR_VisItBroadcastStringCallback() extends IR_VisItFuturePlainFunction {
33
34
35
36
  val str = IR_FunctionArgument("str", IR_PointerDatatype(IR_CharDatatype))
  val len = IR_FunctionArgument("len", IR_IntegerDatatype)
  val sender = IR_FunctionArgument("sender", IR_IntegerDatatype)

37
38
39
  override def generateFct() : IR_PlainFunction = {
    val fctBody = ListBuffer[IR_Statement]()

Richard Angersbach's avatar
Richard Angersbach committed
40
    fctBody += IR_Return(callExtFunction("MPI_Bcast",
41
      str.access, len.access, IR_Native("MPI_CHAR"), sender.access, Knowledge.mpi_defaultCommunicator))
42
43
44
45

    IR_PlainFunction(
      name,
      IR_IntegerDatatype,
46
      ListBuffer(str, len, sender),
47
48
49
50
51
52
53
      fctBody
    )
  }

  override def name : String = "visit_broadcast_string_callback"
}

54
case class IR_VisItSlaveProcessCallback() extends IR_VisItFuturePlainFunction {
55
56
  override def generateFct() : IR_PlainFunction = {
    val fctBody = ListBuffer[IR_Statement]()
57
    val cmdDecl = IR_VariableDeclaration(IR_IntegerDatatype, "command", IR_IntegerConstant(0))
58

59
    fctBody += cmdDecl
Richard Angersbach's avatar
Richard Angersbach committed
60
    fctBody += callExtFunction("MPI_Bcast",
61
      IR_AddressOf(IR_VariableAccess(cmdDecl)), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
62
63
64
65
66
67
68
69
70
71

    IR_PlainFunction(
      name,
      IR_UnitDatatype,
      fctBody
    )
  }

  override def name : String = "slave_process_callback"
}