00001 /* 00002 User-callable C API for TCHARM library 00003 Orion Sky Lawlor, olawlor@acm.org, 11/20/2001 00004 */ 00005 #ifndef __TCHARM_H 00006 #define __TCHARM_H 00007 00008 #include "pup_c.h" 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif 00013 00014 00015 /*User callbacks: you define these functions*/ 00016 void TCHARM_User_node_setup(void); 00017 void TCHARM_User_setup(void); 00018 00019 void TCHARM_Call_fallback_setup(void); 00020 00021 /**** Routines you can call to create threads: ****/ 00022 00023 /*Set the size of the thread stack*/ 00024 void TCHARM_Set_stack_size(int newStackSize); 00025 00026 /*Exit the program when these threads are finished. */ 00027 void TCHARM_Set_exit(void); 00028 00029 /*Get the number of chunks we expect based on the command line*/ 00030 int TCHARM_Get_num_chunks(void); 00031 00032 /*Create a new array of threads, which will be bound to by subsequent libraries*/ 00033 typedef void (*TCHARM_Thread_start_fn)(void); 00034 void TCHARM_Create(int nThreads,int threadFn); 00035 00036 /*As above, but pass along (arbitrary) data to thread*/ 00037 typedef void (*TCHARM_Thread_data_start_fn)(void *threadData); 00038 void TCHARM_Create_data(int nThreads,int threadFn, 00039 void *threadData,int threadDataLen); 00040 int TCHARM_Register_thread_function(TCHARM_Thread_data_start_fn fn); 00041 00042 00043 /**** Routines you can call from the thread (driver) ****/ 00044 int TCHARM_Element(void); 00045 int TCHARM_Num_elements(void); 00046 void TCHARM_Barrier(void); 00047 void TCHARM_Migrate(void); 00048 void TCHARM_Async_Migrate(void); 00049 void TCHARM_Allow_Migrate(void); 00050 void TCHARM_Migrate_to(int destPE); 00051 void TCHARM_Evacuate(); 00052 00053 int TCHARM_System(const char *shell_command); 00054 void TCHARM_Done(int exitcode); 00055 void TCHARM_Yield(void); 00056 00057 /* Set/get thread-private ("thread global") data. */ 00058 typedef void (*TCHARM_Pup_fn)(pup_er p,void *data); 00059 int TCHARM_Register(void *data,TCHARM_Pup_fn pfn); 00060 void *TCHARM_Get_userdata(int id); 00061 00062 /* Alternate API for Set/get thread-private ("thread global") data. */ 00063 typedef void (*TCHARM_Pup_global_fn)(pup_er p); 00064 void TCHARM_Set_global(int globalID,void *new_value,TCHARM_Pup_global_fn pup_or_NULL); 00065 void *TCHARM_Get_global(int globalID); 00066 00067 00068 /*Get the local wall clock. Unlike CkWalltimer, is 00069 monotonically increasing, even with migration and 00070 unsynchronized clocks. */ 00071 double TCHARM_Wall_timer(void); 00072 00073 00074 /*Standalone startup routine*/ 00075 void TCHARM_Init(int *argc,char ***argv); 00076 00077 /*Internal library routine*/ 00078 void TCHARM_In_user_setup(void); 00079 00080 #ifdef __cplusplus 00081 } 00082 #endif 00083 #endif /*def(thisHeader)*/ 00084