示例#1
0
int main(int argc, char *argv[])
{
    int size;
    int version;
    CMEM_BlockAttrs attrs;

    if (argc != 2) {
        fprintf(stderr, "Usage: %s <Number of bytes to allocate>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    size = atoi(argv[1]);

    /* First initialize the CMEM module */
    if (CMEM_init() == -1) {
        fprintf(stderr, "Failed to initialize CMEM\n");
        exit(EXIT_FAILURE);
    }

    printf("CMEM initialized.\n");

    version = CMEM_getVersion();
    if (version == -1) {
        fprintf(stderr, "Failed to retrieve CMEM version\n");
    }
    printf("CMEM version = 0x%x\n", version);

    if (CMEM_getBlockAttrs(0, &attrs) == -1) {
        fprintf(stderr, "Failed to retrieve CMEM memory block 0 bounds\n");
    }
    printf("CMEM memory block 0: phys start = 0x%lx, size = 0x%x\n",
           attrs.phys_base, attrs.size);

    if (CMEM_getBlockAttrs(1, &attrs) == -1) {
        fprintf(stderr, "Failed to retrieve CMEM memory block 1 bounds\n");
    }
    printf("CMEM memory block 1: phys start = 0x%lx, size = 0x%x\n",
           attrs.phys_base, attrs.size);

    testHeap(size, 0);
    testHeap(size, 1);

    testCache(size, 0);
    testCache(size, 1);

    if (CMEM_exit() < 0) {
        fprintf(stderr, "Failed to finalize the CMEM module\n");
    }

    exit(EXIT_SUCCESS);
}
示例#2
0
int main(int argc, char** argv)
{
	IDXGIFactory1* factory = 0;
	CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory);

	IDXGIAdapter* adapter = NULL;
	for (unsigned int index = 0; SUCCEEDED(factory->EnumAdapters(index, &adapter)); ++index)
	{
		DXGI_ADAPTER_DESC ad = {};
		adapter->GetDesc(&ad);

		if (ad.VendorId == 0x1414 && ad.DeviceId == 0x8c)
			continue; // Skip Microsoft Basic Render Driver

		printf("// GPU %d: %S (Vendor %04x Device %04x)\n", index, ad.Description, ad.VendorId, ad.DeviceId);

		if (argc == 1)
		{
			testCache(adapter);
		}
		else if (argc > 1 && strcmp(argv[1], "--") == 0)
		{
			testCacheSequence(adapter, argc, argv);
		}
		else
		{
			testCacheMeshes(adapter, argc, argv);
		}
	}
}
示例#3
0
int main(int argc, char **argv)
{
	int opt;
	static struct option longopts[] = {
		{"help",            no_argument,        0,   'h'},
		{"test",            no_argument,        0,   't'},
		{"simple",          no_argument,        0,   's'},
		{"bare",            no_argument,        0,   'b'},
		{"verbose",         no_argument,        0,   'v'},
		{"logfile",         no_argument,        0,   'l'},
		{"Id",              required_argument,  0,   'A'},
		{"Ib",              required_argument,  0,   'B'},
		{"Dd",              required_argument,  0,   'C'},
		{"Db",              required_argument,  0,   'D'},
		{0, 0, 0, 0}
	};
	int longindex;

	// global simulator options
	bareMachineMode = true;
	quietMode = true;

	// local simulator options
	bool qtSpimLogMode = false;
	unsigned iCacheLogDepth     = 6;
	unsigned iCacheLogBlksize   = 2;
	unsigned dCacheLogDepth     = 6;
	unsigned dCacheLogBlksize   = 2;

	while ((opt = getopt_long_only(argc, argv, "", longopts, &longindex)) != -1) {
		switch (opt) {
			case 'h' :
				printHelp();
				return 0;
			case 't' :
				bareMachineMode = false;
				instructionExecTest();
				testCache();
				return 0;
			case 's' :
				bareMachineMode = false;
				break;
			case 'b' :
				bareMachineMode = true;
				break;
			case 'q' :
				quietMode = false;
				break;
			case 'l' :
				qtSpimLogMode = true;
				break;
			case 'A':   // Id
				iCacheLogDepth = atoi(optarg);
				break;
			case 'B':   // Ib
				iCacheLogBlksize = atoi(optarg);
				break;
			case 'C':   // Dd
				dCacheLogDepth = atoi(optarg);
				break;
			case 'D':   // Db
				dCacheLogBlksize = atoi(optarg);
				break;
			default :
				printf("usage error\n");
				exit(0);
		}
	}

	assert(argc > 1 && "need to specify input file");
	char* infile = argv[optind];

	M.initCache(iCacheLogDepth, iCacheLogBlksize, dCacheLogDepth, dCacheLogBlksize);

	if (qtSpimLogMode)
		M.readSpimLogFile(infile);
	else
		M.readElfFile(infile);

	if (bareMachineMode)
		runBareMachine();
	else
		runSimpleMachine();
	outputStats();
	return 0;
}
示例#4
0
int main(int argc, char *argv[])
{
    size_t size;
    int version;
    CMEM_BlockAttrs attrs;
    int i;
    int c;
    
    non_interactive_flag = FALSE;

    while ((c = getopt(argc, argv, "n")) != -1) {
	switch (c) {
	case 'n':
	    non_interactive_flag = TRUE; 	
	    break;

	default:
	    fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n",
		    argv[0]);
	    fprintf(stderr,
                    "    -n: non-interactive mode (no ENTER prompts)\n");
	    exit(EXIT_FAILURE);
	}
    }

    if ((argc - optind + 1) != 2) {
	fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n",
	        argv[0]);
	fprintf(stderr, "    -n: non-interactive mode (no ENTER prompts)\n");
	exit(EXIT_FAILURE);
    }

    errno = 0;
    size = strtol(argv[optind], NULL, 0);

    if (errno) {
	fprintf(stderr, "Bad argument ('%s'), strtol() set errno %d\n",
	        argv[optind], errno);
        exit(EXIT_FAILURE);
    }

    /* First initialize the CMEM module */
    if (CMEM_init() == -1) {
        fprintf(stderr, "Failed to initialize CMEM\n");
        exit(EXIT_FAILURE);
    }

    printf("CMEM initialized.\n");

    version = CMEM_getVersion();
    if (version == -1) {
	fprintf(stderr, "Failed to retrieve CMEM version\n");
        exit(EXIT_FAILURE);
    }
    printf("CMEM version = 0x%x\n", version);

    testMap(size);
    testAllocPhys(size);

    testCMA(size);

    if (CMEM_getNumBlocks(&nblocks)) {
	fprintf(stderr, "Failed to retrieve number of blocks\n");
        exit(EXIT_FAILURE);
    }
    printf("\n# of CMEM blocks (doesn't include possible CMA global 'block'): %d\n", nblocks);

    if (nblocks) {
	for (i = 0; i < nblocks; i++) {
	    if (CMEM_getBlockAttrs(i, &attrs) == -1) {
		fprintf(stderr, "Failed to retrieve CMEM memory block %d bounds\n", i);
	    }
	    else {
		printf("CMEM memory block %d: phys start = %#llx, size = %#llx\n",
		       i, (unsigned long long)attrs.phys_base, attrs.size);
	    }

	    testHeap(size, i);
	    testHeap(size, i);
	    testPools(size, i);
	    testPools(size, i);
	    testCache(size, i);
	}
    }
    else {
	printf("    no physical block found, not performing block-based testing\n");
    }

    /* block 'nblocks' is the special CMEM CMA "block" */
    testPools(size, CMEM_CMABLOCKID);

    printf("\nexiting...\n");
    if (CMEM_exit() < 0) {
        fprintf(stderr, "Failed to finalize the CMEM module\n");
    }
    printf("...test done\n");

    exit(EXIT_SUCCESS);
}