Informations sur la journalisation et l'exécution du langage Fortran
Cet exemple utilise le nom de fichier suivant : " logrun.f
Coder
Le code de cet exemple explore des fonctionnalités qui ne sont pas forcément utilisées couramment. La journalisation peut être utilisée pour retracer l'exécution d'un AE. Pour être utile, l'AE doit être enregistré avec un masque de journalisation et la journalisation doit être activée via nzudxdbg. Pour recevoir les messages de journalisation du système dans la fenêtre où le système NPS a été démarré, vous devez démarrer NPS avec l'option '-i' (par exemple, "nzstart -i'). Les processus NPS restent ainsi attachés au terminal. Les informations sur l'exécution fournissent des statistiques sur le système NPS, notamment le nombre de tranches de données, le nombre de SPU et le lieu d'exécution.
program logRunUdtf
call nzaeRun()
stop
end
subroutine nzaeHandleRequest(handle)
character(100) infoString
integer infoInt, isSpu, isUdf, isUda, isUdtf
double precision infoDouble
infoString = "init"
infoDouble = -1
infoInt = -1
isSpu = -1
isUda = -1
isUdf = -1
isUdtf = -1
c IGNORE ALL INPUT.
10 call nzaeGetNext(handle, hasNext)
if (hasNext .eq. 1) then
goto 10
endif
c OUTPUT WHERE WE ARE RUNNING.
call nzaeSetOutputString(handle, 0, "Host or Spu?")
call nzaeIsRunningOnSpu(handle, isSpu)
if (isSpu .eq. 1) then
call nzaeSetOutputString(handle, 1, "host")
else
call nzaeSetOutputString(handle, 1, "spu")
endif
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputNull(handle, 3)
call nzaeOutputResult(handle)
c OUTPUT SUGGESTED MEMORY LIMIT.
call nzaeGetSuggestedMemoryLimit(handle, infoDouble)
call nzaeSetOutputString(handle, 0, "Memory Limit")
call nzaeSetOutputNull(handle, 1)
call nzaeSetOutputDouble(handle, 2, infoDouble)
call nzaeSetOutputNull(handle, 3)
call nzaeOutputResult(handle)
c OUTPUT IS-USER-QUERY.
call nzaeIsUserQuery(handle, infoInt)
call nzaeSetOutputString(handle, 0, "User Query?")
if (infoInt .eq. 1) then
call nzaeSetOutputString(handle, 1, "Yes")
else
call nzaeSetOutputString(handle, 1, "No")
endif
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputNull(handle, 3)
call nzaeOutputResult(handle)
c OUTPUT ADAPTER TYPE.
call nzaeIsUdf(handle, isUdf)
call nzaeIsUda(handle, isUda)
call nzaeIsUdtf(handle, isUdtf)
call nzaeSetOutputString(handle, 0, "Adapter Type")
if (isUdf .eq. 1) then
call nzaeSetOutputString(handle, 1, "udf")
endif
if (isUda .eq. 1) then
call nzaeSetOutputString(handle, 1, "uda")
endif
if (isUdtf .eq. 1) then
call nzaeSetOutputString(handle, 1, "udtf")
endif
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputNull(handle, 3)
call nzaeOutputResult(handle)
c OUTPUT DATA SLICE ID.
call nzaeGetDataSliceId(handle, infoInt)
call nzaeSetOutputString(handle, 0, "Dataslice ID")
call nzaeSetOutputNull(handle, 1)
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputInt32(handle, 3, infoInt)
call nzaeOutputResult(handle)
c OUTPUT TRANSACTION ID.
call nzaeGetTransactionId(handle, infoString)
call nzaeSetOutputString(handle, 0, "Transaction ID")
call nzaeSetOutputString(handle, 1, infoString)
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputNull(handle, 3)
c OUTPUT HARDWARE ID.
call nzaeGetHardwareId(handle, infoString)
call nzaeSetOutputString(handle, 0, "Hardware ID")
call nzaeSetOutputString(handle, 1, infoString)
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputNull(handle, 3)
call nzaeOutputResult(handle)
c OUTPUT NUMBER OF DATASLICES.
call nzaeGetNumberOfDataslices(handle, infoInt)
call nzaeSetOutputString(handle, 0, "Number of Dataslices")
call nzaeSetOutputNull(handle, 1)
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputInt32(handle, 3, infoInt)
call nzaeOutputResult(handle)
c OUTPUT NUMBER OF SPUS.
call nzaeGetNumberOfSpus(handle, infoInt)
call nzaeSetOutputString(handle, 0, "Number of Spus")
call nzaeSetOutputNull(handle, 1)
call nzaeSetOutputNull(handle, 2)
call nzaeSetOutputInt32(handle, 3, infoInt)
call nzaeOutputResult(handle)
c DO SOME LOGGING.
call nzaeLog(handle, "Here is some logging text!")
call nzaeLog(handle, "Here is some more logging text!")
return
end
Compilation
Utiliser la compilation standard :
$NZ_EXPORT_DIR/ae/utilities/bin/compile_ae --language fortran --version 3 \
--template compile logrun.f
Enregistrement
Enregistrez l'exemple en utilisant les options --mem et --mask. L'option --mask active la journalisation pour DEBUG et l'option --mem définit les informations sur la durée d'exécution de la mémoire.
$NZ_EXPORT_DIR/ae/utilities/bin/register_ae --language fortran --version 3 \
--template udtf --exe logrun --sig "log_run(int4)" \
--return "table(name varchar(100), val_str varchar(100), \
val_double double, val_int int4)" --mem 100k --mask debug
En cours d'exécution
Avant de commencer, activez la journalisation en exécutant nzudxdbg:
nzudxdbg
Processing 1 spus
.
done
Processing host
done
Exécutez la requête dans nzsql :
SELECT * FROM TABLE WITH FINAL(log_run(1));
NAME | VAL_STR | VAL_DOUBLE | VAL_INT
----------------------+---------+------------+---------
Host OR Spu? | spu | |
Memory LIMIT | | 102400 |
User Query? | Yes | |
Adapter Type | udtf | |
Dataslice ID | | | 0
Hardware ID | 0 | |
Number of Dataslices | | | 4
Number of Spus | | | 1
L'enregistrement du système NPS apparaît dans la fenêtre où le système NPS a été démarré :
05-05-10 14:33:18 (dbos.18728) [d,udx ] Here is some logging text!
05-05-10 14:33:18 (dbos.18728) [d,udx ] Here is some more logging text!