예제 #1
0
  void QuizSubmission::loadAnswers(Session &session, AsyncCallback callback) {
    Json::Value qqDocuments;
    Json::Reader reader;

    session.get("/quiz_submissions/" + Utility::stringify(id()) + "/questions",
      [&, callback](bool success, HTTP::Response const& response) {
        if (success) {
          loadAnswers(response.body);

          if (callback) {
            callback(true);
          }
        }
        else {
          if (callback) {
            callback(false);
          }
        }
      });
  }
예제 #2
0
int main()
{
	void* virtual_base;
	int fd;
	void* sdram_ptr;

	if(setup(&fd, &virtual_base) != 0)
	{
		return(1);
	}

	sdram_ptr = virtual_base + ((unsigned long)(SDRAM_OFST + 0x00) & (unsigned long)(HW_REGS_MASK));

	// DO STUFF HERE

	int answers[NUMTEST];
	if(loadAnswers(answers) == -1)
	{
		return -1;
	}

	// Load weight and bias data into SDRAM ( WORKING )
	if(loadWBData(sdram_ptr) == -1)
	{
		return -1;
	}

	// Use to test SDRAM weight/bias loading, comment out if not testing.
	// testSDRAMLoad(sdram_ptr);

	int results[NUMTEST];
	if(performTests(sdram_ptr, results) == -1)
	{
		return -1;
	}
	printf("Computing Accuracy...\n");
	int i;
	int correct = 0;
	for(i = 0; i < NUMTEST; i++)
	{
		if(answers[i] == results[i])
		{
			correct++;
		}
		else
		{
			printf("Incorrect result for test %d\nExpected: %d\nReceived: %d\n\n", i, answers[i], results[i]);
		}
	}
	printf("\nAccuracy: %3.2lf%%\n", ((double)correct / (double)NUMTEST) * 100);

	// Closing out
	if(munmap(virtual_base, HW_REGS_SPAN) != 0)
	{
		printf("ERROR: munmap() failed...\n");
		close(fd);
		return(1);
	}
	close(fd);

	return 0;
}
예제 #3
0
int main()
{
	void* sdram_base, * ipc_base;
	int fd;
	void* sdram_ptr;
	volatile void* ready, * done;

	if(setup(&fd, &sdram_base, &ipc_base) != 0)
	{
		return(1);
	}

	sdram_ptr = sdram_base + ((unsigned long)(SDRAM_OFST + 0x00) & (unsigned long)(SDRAM_MASK));
	ready = ipc_base + ((unsigned long)(ALT_LWFPGALVS_OFST + 0xA0) & (unsigned long)(HW_REGS_MASK));
	done = ipc_base + ((unsigned long)(ALT_LWFPGALVS_OFST + 0x90) & (unsigned long)(HW_REGS_MASK));

	// DO STUFF HERE

	// testReadyDone(ready, done);

	int answers[NUMTEST];
	if(loadAnswers(answers) == -1)
	{
		return -1;
	}

	// Load weight and bias data into SDRAM ( WORKING )
	if(loadWBData(sdram_ptr) == -1)
	{
		return -1;
	}

	// Use to test SDRAM weight/bias loading, comment out if not testing.
	// testSDRAMLoad(sdram_ptr);

	int results[NUMTEST];
	clock_t start, finish;
	start = clock();
	if(performTests(sdram_ptr, ready, done, results) == -1)
	{
		return -1;
	}
	finish = clock();

	int i;
	for(i = 0; i < 175; i++)
	{
		printf("L1 data: %d\n", ((short*)sdram_ptr)[T_OFST + i]);
	}

	printf("Compute time: %lf\n", (double)(finish - start) / CLOCKS_PER_SEC);
	printf("Computing Accuracy...\n");
	int correct = 0;
	for(i = 0; i < NUMTEST; i++)
	{
		if(answers[i] == results[i])
		{
			correct++;
		}
		else
		{
			printf("Incorrect result for test %d\nExpected: %d\nReceived: %d\n\n", i, answers[i], results[i]);
		}
	}
	printf("\nNumber Correct: %d\nAccuracy: %3.2lf%%\n", correct, ((double)correct / (double)NUMTEST) * 100);

	// Closing out
	if(munmap(sdram_base, SDRAM_SPAN) != 0)
	{
		printf("ERROR: munmap() failed...\n");
		close(fd);
		return(1);
	}
	close(fd);

	return 0;
}