00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <tcl.h>
00022 #include <ctype.h>
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <string.h>
00026 #include "Benchmark.h"
00027 #include "config.h"
00028 #include "VMDApp.h"
00029 #include "TclCommands.h"
00030 #include "CUDAKernels.h"
00031 #include "CUDAAccel.h"
00032 #include "WKFThreads.h"
00033 #include "ProfileHooks.h"
00034
00035 static void cmd_profile_usage(Tcl_Interp *interp) {
00036 Tcl_AppendResult(interp,
00037 "usage: profile <command> [args...]\n"
00038 "profile start\n",
00039 "profile stop\n",
00040 "profile push_range <tag string>\n",
00041 "profile pop_range\n",
00042 "(*) Only available in CUDA-enabled builds of VMD\n",
00043 NULL);
00044 }
00045
00046 int text_cmd_profile(ClientData cd, Tcl_Interp *interp, int argc, const char *argv[]) {
00047 #if 0 && defined(VMDCUDA) && defined(VMDNVTX)
00048 VMDApp *app = (VMDApp *)cd;
00049 #endif
00050
00051 if (argc == 1) {
00052 cmd_profile_usage(interp);
00053 return TCL_ERROR;
00054 }
00055
00056 if (argc >= 2) {
00057 #if !(defined(VMDCUDA) && defined(VMDNVTX))
00058 Tcl_AppendResult(interp, "CUDA Acceleration not available in this build", NULL);
00059 return TCL_ERROR;
00060 #else
00061 if (!strupncmp(argv[1], "start", CMDLEN)) {
00062 PROFILE_START();
00063 Tcl_AppendResult(interp, "Starting profiling", NULL);
00064 return TCL_OK;
00065 } else if (!strupncmp(argv[1], "stop", CMDLEN)) {
00066 PROFILE_STOP();
00067 Tcl_AppendResult(interp, "Stopping profiling", NULL);
00068 return TCL_OK;
00069 } else if (!strupncmp(argv[1], "push_range", CMDLEN)) {
00070 if (argc >= 3) {
00071 PROFILE_PUSH_RANGE(argv[2], 2);
00072 }
00073 return TCL_OK;
00074 } else if (!strupncmp(argv[1], "pop_range", CMDLEN)) {
00075 PROFILE_POP_RANGE();
00076 return TCL_OK;
00077 } else {
00078 cmd_profile_usage(interp);
00079 return TCL_ERROR;
00080 }
00081 #endif
00082 } else {
00083 cmd_profile_usage(interp);
00084 return TCL_ERROR;
00085 }
00086
00087
00088 return TCL_OK;
00089 }
00090
00091