static void *alloc_gpu_mem(uint32_t type, uint32_t size, uint32_t attribs, SceUID *uid) { int ret; void *mem = NULL; if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) size = align_mem(size, 256 * 1024); else size = align_mem(size, 4 * 1024); *uid = sceKernelAllocMemBlock("gxm", type, size, NULL); printf("MemBlock uid: 0x%08X\n", *uid); ret = sceKernelGetMemBlockBase(*uid, &mem); printf("sceKernelGetMemBlockBase(): 0x%08X\n", ret); printf("MemBlockBase addr: %p\n", mem); if (ret != 0) { return NULL; } ret = sceGxmMapMemory(mem, size, attribs); printf("sceGxmMapMemory(): 0x%08X\n", ret); if (ret != 0) { return NULL; } return mem; }
/* Function : matrix_init Initialize the memory block for matrix benchmarking. Parameters: blksize - Size of memory to be initialized. memblk - Pointer to memory block. seed - Actual values chosen depend on the seed parameter. p - pointers to <mat_params> containing initialized matrixes. Returns: Matrix dimensions. Note: The seed parameter MUST be supplied from a source that cannot be determined at compile time */ ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params * p) { ee_u32 N = 0; MATDAT *A; MATDAT *B; ee_s32 order = 1; MATDAT val; ee_u32 i = 0, j = 0; if (seed == 0) seed = 1; while (j < blksize) { i++; j = i * i * 2 * 4; } N = i - 1; A = (MATDAT *) align_mem(memblk); B = A + N * N; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { seed = ((order * seed) % 65536); val = (seed + order); val = matrix_clip(val, 0); B[i * N + j] = val; val = (val + order); val = matrix_clip(val, 1); A[i * N + j] = val; order++; } } p->A = A; p->B = B; p->C = (MATRES *) align_mem(B + N * N); p->N = N; #if CORE_DEBUG printmat(A, N, "A"); printmat(B, N, "B"); #endif return N; }
int main(int argc, char *argv[]) { int r = EXIT_OK; int i, ii; int m; time_t t_total; #if defined(__EMX__) _response(&argc,&argv); _wildcard(&argc,&argv); #endif if (argv[0]) argv0 = argv[0]; align_mem(); (void) my_clock(); printf("\nLZO real-time data compression library (v%s, %s).\n", LZO_VERSION_STRING, LZO_VERSION_DATE); printf("Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n\n"); if (lzo_init() != LZO_E_OK) { printf("lzo_init() failed !!!\n"); exit(EXIT_LZO_INIT); } if (argc < 2) usage(argv0,-1,0); i = get_options(argc,argv); if (methods_n == 0) add_method(default_method); if (methods_n > 1 && opt_read_from_stdin) { printf("%s: cannot use multiple methods and '-@'\n", argv0); exit(EXIT_USAGE); } if (opt_block_size < 16) opt_block_size = 16; if (opt_block_size > MAX_BLOCK_SIZE) opt_block_size = MAX_BLOCK_SIZE; dict_len = 0; #ifndef USE_DICT opt_dict = 0; #else if (opt_dict) { opt_optimize_compressed_data = 0; if (opt_dictionary_file) { read_dict(opt_dictionary_file); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; if (dict_len > 0) printf("Using dictionary '%s', %ld bytes, ID 0x%08lx.\n", opt_dictionary_file, (long) dict_len, (long) dict_adler32); } if (dict_len <= 0) { init_default_dict(); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; printf("Using default dictionary, %ld bytes, ID 0x%08lx.\n", (long) dict_len, (long) dict_adler32); } if (opt_max_dict_len == -1) printf("Dictionary size will be adjusted to file size.\n"); else if (opt_max_dict_len <= 0) printf("Dictionary size will be adjusted to file size.\n"); } #endif t_total = time(NULL); (void) my_clock(); ii = i; for (m = 0; m < methods_n && r == EXIT_OK; m++) { int method = methods[m]; i = ii; if (i >= argc && opt_calgary_corpus_path == NULL && !opt_read_from_stdin) usage(argv0,-1,0); if (m == 0 && opt_verbose >= 1) printf("%lu block-size\n\n", (long) opt_block_size); if (!info(method,NULL)) info(method,stdout); #ifdef USE_CORPUS if (opt_calgary_corpus_path != NULL) r = do_corpus(calgary_corpus,method,opt_calgary_corpus_path, opt_c_loops,opt_d_loops); else #endif { for ( ; i < argc && r == EXIT_OK; i++) { r = do_file(method,argv[i],opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } if (opt_read_from_stdin) { char buf[512], *p; while (r == EXIT_OK && fgets(buf,sizeof(buf)-1,stdin) != NULL) { buf[sizeof(buf)-1] = 0; p = buf + strlen(buf); while (p > buf && is_space(p[-1])) *--p = 0; p = buf; while (*p && is_space(*p)) p++; if (*p) r = do_file(method,p,opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } opt_read_from_stdin = 0; } } } t_total = time(NULL) - t_total; if (opt_totals) print_totals(); if (opt_execution_time || (methods_n > 1 && opt_verbose >= 1)) printf("\n%s: execution time: %lu seconds\n", argv0, (long) t_total); if (r != EXIT_OK) printf("\n%s: exit code: %d\n", argv0, r); return r; }