Exemplo n.º 1
0
/* initialise everything */
void PicocInitialise(Picoc *pc, int StackSize)
{
	memset(pc, '\0', sizeof(*pc));
	PlatformInit(pc);
	BasicIOInit(pc);
	HeapInit(pc, StackSize);
	TableInit(pc);
	VariableInit(pc);
	LexInit(pc);
	TypeInit(pc);

#ifndef NO_HASH_INCLUDE
	IncludeInit(pc);
#endif

	LibraryInit(pc);

#ifdef BUILTIN_MINI_STDLIB
	LibraryAdd(pc, &pc->GlobalTable, "c library", &CLibrary[0]);
	CLibraryInit(pc);
#endif

	PlatformLibraryInit(pc);
	DebugInit(pc);
}
Exemplo n.º 2
0
/* initialise everything */
void PicocInitialise(int StackSize)
{
    BasicIOInit();
    HeapInit(StackSize);
    TableInit();
    VariableInit();
    LexInit();
    TypeInit();
#ifndef NO_HASH_INCLUDE
    IncludeInit();
#endif
    LibraryInit();
#ifdef BUILTIN_MINI_STDLIB
    LibraryAdd(&GlobalTable, "c library", &CLibrary[0]);
    CLibraryInit();
#endif
    PlatformLibraryInit();
}
Exemplo n.º 3
0
void Train(int argc, char* argv[]) {
  NumInit();
  VariableInit(argc, argv);  //  >>
  MainWork prepper = NULL, cleaner = NULL;
  ThreadTrain trainer = NULL;
  if (!strcmp(V_TRAIN_METHOD, "dcme")) {
    prepper = DcmePrep;
    trainer = DcmeThreadTrain;
    cleaner = DcmeClean;
  } else if (!strcmp(V_TRAIN_METHOD, "w2v")) {
    prepper = W2vPrep;
    trainer = W2vThreadTrain;
    cleaner = W2vClean;
  } else if (!strcmp(V_TRAIN_METHOD, "nsme")) {
    prepper = NsmePrep;
    trainer = NsmeThreadTrain;
    cleaner = NsmeClean;
  }
  if (prepper) prepper();
  if (trainer) {
    long int tid;
    // schedule thread jobs
    pthread_t* pt = (pthread_t*)malloc(V_THREAD_NUM * sizeof(pthread_t));  // >>
    for (tid = 0; tid < V_THREAD_NUM; tid++)
      pthread_create(&pt[tid], NULL, trainer, (void*)tid);
    for (tid = 0; tid < V_THREAD_NUM; tid++) pthread_join(pt[tid], NULL);
    free(pt);  // <<
    LOGCR(2);
  }
  if (cleaner) cleaner();
  WeightSave(weight, C, N, -1, V_WEIGHT_SAVE_PATH);  // save model
  VariableFree();                                    // <<
  LOG(1, "\nTraining finished. Took time %s\n",
      strclock(start_clock_t, clock(), V_THREAD_NUM));
  return;
}