elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


  Mostrar Temas
Páginas: 1 2 3 4 5 6 [7] 8 9 10 11 12
61  Seguridad Informática / Criptografía / Encuesta: Creando un algoritmo entre todos! en: 1 Octubre 2010, 20:10 pm
Hola gente!!
Como va todo?
Bueno, me propuse como fin levantar la actividad de este subforo que realmente tiene muchísimo potencial y trata de un tema súmamente interesante y de gran importancia en la actualidad.

Para esto, necesito a todos ustedes, los que cada vez que ven un texto cifrado, un hash o una imagen sospechosa, les pica el bicho de la curiosidad y quieren saber que hay detrás de esa maraña de caracteres sin orden aparente.

Entonces, se me ocurrió comenzar un taller para que todos los que estén interesados, se apunten, aporten sus conocimientos y aprendan nuevas cosas, el fin de este taller sería crear un algoritmo nuevo, optimizarlo y hacerle criptoanálisis para probar su seguridad.
Lo único que hace falta definir, es sobre que campo de la criptografía nos vamos a desarrollar:
Criptografía asimétrica?
Criptografía simétrica?
Hashes?
Esteganografía?

Es importante que digan que algoritmo les interesa, aparte de ponerlo en la encuesta y aclarar si pueden leer textos en inglés.

Bueno, escucho sus opiniones y sus aportes.

Muchas gracias a todos!
Un abrazo
APOKLIPTICO

Quiénes se han anotado:
- APOKLIPTICO (Simétrico) Inglés: Si.
- Debci (????) Inglés: ????.
- Freeze. (Simétrico) Inglés: Si.
- 16BITBoy. (Hash) Inglés: ???
- MasterPunk (Asimétrico) Inglés: Si.
- Liena. (Asimétrico) Inglés: ???
- Bomba1990. (Asimétrico) Inglés: ???
- Raul338 (Asimétrico) Inglés: Si.
- [D4N93R] (Esteganografía) Inglés:Si.
- WestOn (Asimétrico) Inglés: Si.
- Braulio-- (Hash) Inglés: Si.
62  Programación / Programación C/C++ / Falta libnet.dll.a en: 1 Octubre 2010, 03:11 am
Perdón Vertex, pero no sabía si ponerlo ak o en Progamacion C/C++.

El problema es el siguiente: Estoy compilando ettercap-ng bajo mingw32, compiló perfecto con un par de warnings que si el programa despues no funciona bien, las resolveré pero por ahora compila bien, el problema es cuando quiero linkearlo.
Me pide un "libnet.dll.a" yo tengo uno llamado "libnet.a" lo copié y le puse "libnet.dll.a", pero obviamente eso no resolvió el problema.
Me tira un montón de Undefined references, específicamente a estas funciones:

Código
  1. ../libnet/lib/libnet.dll.a(libnet_resolve.o):libnet_resolve.c:(.text+0x5da): undefined reference to `PacketGetNetInfoEx'
  2. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0xdf): undefined reference to `PacketSetBuff'
  3. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0xf4): undefined reference to `PacketGetNetType'
  4. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x262): undefined reference to `PacketSetHwFilter'
  5. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x289): undefined reference to `PacketAllocatePacket'
  6. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x2dc): undefined reference to `PacketInitPacket'
  7. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x2f9): undefined reference to `PacketSendPacket'
  8. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x30e): undefined reference to `PacketFreePacket'
  9. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x56d): undefined reference to `SendARP@16'
  10. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x597): undefined reference to `GetAdaptersInfo@8'
  11. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x5c5): undefined reference to `GetAdaptersInfo@8'
  12. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x627): undefined reference to `SendARP@16'
  13. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x6d6): undefined reference to `GetIpNetTable@12'
  14. ../libnet/lib/libnet.dll.a(libnet_link_win32.o):libnet_link_win32.c:(.text+0x72b): undefined reference to `GetIpNetTable@12'
  15. ../libnet/lib/libnet.dll.a(libnet_write.o):libnet_write.c:(.text+0x521): undefined reference to `PacketGetNetType'
  16. ../libnet/lib/libnet.dll.a(libnet_write.o):libnet_write.c:(.text+0x60d): undefined reference to `PacketAllocatePacket'
  17. ../libnet/lib/libnet.dll.a(libnet_write.o):libnet_write.c:(.text+0x660): undefined reference to `PacketInitPacket'
  18. ../libnet/lib/libnet.dll.a(libnet_write.o):libnet_write.c:(.text+0x67d): undefined reference to `PacketSendPacket'
  19. ../libnet/lib/libnet.dll.a(libnet_write.o):libnet_write.c:(.text+0x692): undefined reference to `PacketFreePacket'
  20.  

Alguien me podría aclarar un poco esto?
Gracias!
63  Programación / Programación General / Cuda Vs Stream?? STREAM!! en: 30 Septiembre 2010, 23:58 pm
Hola gente, como va todo, hoy les traigo algo que realmente a muchos les va a interesar.

Muchos ya han escuchado la nueva tecnología que permite utilizar la capacidad de procesamiento de la GPU, para hacer cálculos matemáticos de alta complejidad esto tiene el nombre de GPGPU (General Purpose Graphic Processing Unit). Para esto existen varias tecnologías, Nvidia sacó su CUDA (Compute Unified Device Architecture) y Ati sacó su FireStream. También existen diversos lenguajes que se han creado ad-hoc para optimizar el acceso a esta capacidad como Brook+, CAL y algunas librerías para gráficos de juegos como PhysX y Bullet.

Pero sin embargo, hay una tecnología que a mi opinion va a ser el futuro del GPGPU, estoy hablando claramente del OpenCL una api que cross-platform que permite utilizar tanto Stream como Cuda y en caso de que ninguna de las dos esté disponible, utilizar la CPU.

Es por esto que me puse a analizar la capacidad de cálculo de las últimas placas de Nvidia y de Ati.
Para esto, utilizo el FLOPS (Operación de coma flotante por segundo) como unidad de medida.

Para hacer el cálculo de la capacidad de cálculo utilizo esta fórmula:
[Stream/CUDA cores] * 2 * [GPU clock] = Capacidad de cálculo en MFLOPS.

Tomo entonces distintas placas y las comparo:
Nvidia Geforce GTX 480 (La última de Nvidia) = 672 GFLOPS.
Nvidia Geforce GTX 295 (La última del ensamblador XFX) = 553 GFLOPS.
Ati HD4850 (La que tengo yo XD) = 1040 GFLOPS.
Ati HD5970 (La última de ATI) = 4640 GFLOPS (!).
Ati HD5970 Black Edition Limited (La última del ensamblador XFX = 5440 GFLOPS (!!!)

Ahora, claramente podemos ver que las Ati tienen una capacidad de procesamiento mucho mayor a las Nvidia en cuanto a GPGPU.

Ustedes que piensan?
Un abrazo
APOKLIPTICO
64  Seguridad Informática / Seguridad / TLS y RC4, posible falla? en: 29 Septiembre 2010, 20:14 pm
Hola gente, como va todo, hoy estaba mirando el certificado de una página y me di cuenta que utiliza como algoritmo de cifrado RC4, osea que debe de ser una combinación RSA-RC4, se envía mediante criptografía asimétrica la clave simétrica y esa es la que sutiliza para cifrar los mensajes que van y vienen.
Ahora, siendo que el algoritmo efectivo con el cual se cifran los datos es RC4 y todos sabemos que si se tienen suficientes IVs de dicho algoritmo, se puede llegar a conseguir la clave y efectivamente descifrar los datos como vimos en el algoritmo WEP.
Esto no se podría utilizar para crackear la clave RC4 de un canal seguro TLS?

Un abrazo
APOKLIPTICO
65  Seguridad Informática / Criptografía / Cryptool 1.4.3 y Cryptool 2.0 Beta. en: 29 Septiembre 2010, 05:56 am
Hola gente, como va todo? Hoy les traigo dos pedazos de software que realmente les van a sacar las papas del fuego en más de una ocasión.
El primero es cryptool 1.4.3, trae numerosas opciones, ya sea de cifrar/descifrar en varios algoritmos nuevos y antiguos, varios criptoanálisis distintos como análisis de frecuencias, entropía, etc. y por último varios tutoriales educativos sobre distintos algoritmos famosos como RSA.



Por otro lado, tenemos a la nueva version de Cryptool 2.0, aún en Beta.


Esta versión introduce unos nuevos cambios, primero la capacidad de incorporar algoritmos como plugins y por otro lado, una visión más gráfica de cada algoritmo, pudiendo incorporar compuertas lógicas, contadores, e incluso crackeadores.

En mi opinión, a la versión 2.0 todavía le falta trabajo y yo la verdad no soy muy fanático de los programas con GUIs demasiado pesados, pero aún asi, permite ver de manera muy clara todos los algoritmos.

Bueno, espero que les guste, les dejo la página para que los puedan descargar.
http://www.cryptool.org/

Un abrazo
APOKLIPTICO
66  Seguridad Informática / Hacking Wireless / Hashes, Mic, algoritmos WPA! en: 27 Septiembre 2010, 20:24 pm
Hola gente del foro.
Bueno, como veo que mi post anterior no tuvo respuestas, quizas debería hacer un approach mas focalizado en cuanto a mis preguntas.
Estuve leyendo sobre los últimos avances a los ataques sobre WPA+TKIP (Beck-Tews, Ohigashi-Morii attack) y sobre los ya existentes ataques sobre WEP y el algoritmo RC4 (FMS, KOREK, PTW, Vaudenay-Vuagnoux).
Tengo este diagrama:


El tema es que este diagrama da cierta ambigüedad a partes del algoritmo.
1) La "Master key" es la clave WPA (la de 8-63 bytes que se escribe en el setup del router) o la pairwise master key (PMK) que es la clave WPA pasada por el PBKDF2???

2) De donde se sacan la MIC key y la encryption key??? del PBKDF2??? donde están los 64 bits restantes (PBKDF2 = 256 bits: encryption key 128 bits + MIC key 64 bits = 192 bits)???

3) El algoritmo de "hash()" que se da con el IV del RC4 y la encryption key, se hace con cada paquete?? Cual es este algoritmo? MD5? alguno creado ad-hoc?.

Por favor, si alguien puede responder aunque sea una de estas preguntas o mostrarme algún lugar explicativo del algoritmo TKIP, estaría muy agradecido.
67  Seguridad Informática / Hacking Wireless / Preguntas sobre el algoritmo WPA + TKIP. en: 22 Septiembre 2010, 22:40 pm
Hola gente, estoy pensando en una posible implementación que podría reducir el tiempo y los IVs necesarios para crackear un clave WEP y potencialmente dar un paso más hacia el crackeo del WPA+TKIP.
Pero tengo un par de preguntas al respecto sobre el algoritmo.
1) Que algoritmo (Hash supongo) se utiliza para obtener de la clave WPA la key para luego generar el keystream del RC4?
2.a) Si yo tuviese hipotéticamente suficientes keystreams descifrados con el nuevo método derivado del chop-chop (.xor), podría llegar a conseguir el key del RC4?
2.b) Si pudiese conseguir este key, podría entonces utilizarlo para inyectar paquetes indefinidamente? o ahí entra en juego el key renewal del WPA?.
3) Hay algún lugar donde esté bien explicado el algoritmo WPA+TKIP, como existe para el NTFS la página NTFS.org?
Muchas gracias.
Un abrazo
APOKLIPTICO
68  Programación / Programación C/C++ / OpenCL + Ati STREAM + CUDA. en: 22 Septiembre 2010, 16:57 pm
Hola gente, como va todo? Acabo de compilar un programa de prueba que utiliza OpenCL. OpenCL es una plataforma que unifica el GPGPU, realmente me pareció muy buena, el tema es que yo solo tengo una Ati HD4850, no tengo ninguna Nvidia para probar, alguien podría hacerme el favor?? Osea, en definitiva lo que necesitaría es el vendor ID de nvidia para agregarlo al programa, una vez que haga esto, se puede adaptar para que funcione con ambas plataformas! No es genial?.

Bueno este es el código en cuestion, se basa en un template de el SDK de Ati Stream modificado, este es el código en cuestión:

main.cpp:


Código
  1. #include "main.hpp"
  2. std::string
  3. convertToString(const char *filename)
  4. {
  5.    size_t size;
  6.    char*  str;
  7.    std::string s;
  8.  
  9.    std::fstream f(filename, (std::fstream::in | std::fstream::binary));
  10.  
  11.    if(f.is_open())
  12.    {
  13.        size_t fileSize;
  14.        f.seekg(0, std::fstream::end);
  15.        size = fileSize = f.tellg();
  16.        f.seekg(0, std::fstream::beg);
  17.  
  18.        str = new char[size+1];
  19.        if(!str)
  20.        {
  21.            f.close();
  22.            return NULL;
  23.        }
  24.  
  25.        f.read(str, fileSize);
  26.        f.close();
  27.        str[size] = '\0';
  28.  
  29.        s = str;
  30.        delete[] str;
  31.        return s;
  32.    }
  33.    else
  34.    {
  35.        std::cout << "\nFile containg the kernel code(\".cl\") not found. Please copy the required file in the folder containg the executable.\n";
  36.        exit(1);
  37.    }
  38.    return NULL;
  39. }
  40. int
  41. initializeHost(void)
  42. {
  43.    width               = 102400;
  44.    output                = NULL;
  45.  
  46.    /////////////////////////////////////////////////////////////////
  47.    // Allocate and initialize memory used by host
  48.    /////////////////////////////////////////////////////////////////
  49.    cl_uint sizeInBytes = width * sizeof(cl_uint);
  50.  
  51.    output = (cl_uint *) malloc(sizeInBytes);
  52.    if(output == NULL)
  53.    {
  54.        std::cout<<"Error: Failed to allocate output memory on host\n";
  55.        return 1;
  56.    }
  57.  
  58.    return 0;
  59. }
  60. int
  61. initializeCL(bool UseGPU)
  62. {
  63.    cl_int status = 0;
  64.    size_t deviceListSize;
  65.  
  66.    /*
  67.      * Have a look at the available platforms and pick either
  68.      * the AMD one if available or a reasonable default.
  69.      */
  70.  
  71.    cl_uint numPlatforms;
  72.    cl_platform_id platform = NULL;
  73.    status = clGetPlatformIDs(0, NULL, &numPlatforms);
  74.    if(status != CL_SUCCESS)
  75.    {
  76.        std::cout << "Error: Getting Platforms. (clGetPlatformsIDs)\n";
  77.        return 1;
  78.    }
  79.  
  80.    if(numPlatforms > 0)
  81.    {
  82.        cl_platform_id* platforms = new cl_platform_id[numPlatforms];
  83.        status = clGetPlatformIDs(numPlatforms, platforms, NULL);
  84.        if(status != CL_SUCCESS)
  85.        {
  86.            std::cout << "Error: Getting Platform Ids. (clGetPlatformsIDs)\n";
  87.            return 1;
  88.        }
  89.        for(unsigned int i=0; i < numPlatforms; ++i)
  90.        {
  91.            char pbuff[100];
  92.            status = clGetPlatformInfo(
  93.                        platforms[i],
  94.                        CL_PLATFORM_VENDOR,
  95.                        sizeof(pbuff),
  96.                        pbuff,
  97.                        NULL);
  98.            if(status != CL_SUCCESS)
  99.            {
  100.                std::cout << "Error: Getting Platform Info.(clGetPlatformInfo)\n";
  101.                return 1;
  102.            }
  103.            platform = platforms[i];
  104.            if(!strcmp(pbuff, "Advanced Micro Devices, Inc."))
  105.            {
  106.                break;
  107.            }
  108.        }
  109.        delete platforms;
  110.    }
  111.  
  112.    if(NULL == platform)
  113.    {
  114.        std::cout << "NULL platform found so Exiting Application." << std::endl;
  115.        return 1;
  116.    }
  117.  
  118.    /*
  119.      * If we could find our platform, use it. Otherwise use just available platform.
  120.      */
  121.    cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform, 0 };
  122.  
  123.    /////////////////////////////////////////////////////////////////
  124.    // Create an OpenCL context
  125.    /////////////////////////////////////////////////////////////////
  126.    if(UseGPU) context = clCreateContextFromType(cps, CL_DEVICE_TYPE_GPU, NULL, NULL, &status);
  127.    else context = clCreateContextFromType(cps, CL_DEVICE_TYPE_CPU, NULL, NULL, &status);
  128.    if(status != CL_SUCCESS)
  129.    {
  130.        std::cout<<"Error: Creating Context. (clCreateContextFromType)\n";
  131.        return 1;
  132.    }
  133.  
  134.    /* First, get the size of device list data */
  135.    status = clGetContextInfo(context,
  136.                              CL_CONTEXT_DEVICES,
  137.                              0,
  138.                              NULL,
  139.                              &deviceListSize);
  140.    if(status != CL_SUCCESS)
  141.    {
  142.        std::cout<<
  143.            "Error: Getting Context Info \
  144.            (device list size, clGetContextInfo)\n";
  145.        return 1;
  146.    }
  147.  
  148.    /////////////////////////////////////////////////////////////////
  149.    // Detect OpenCL devices
  150.    /////////////////////////////////////////////////////////////////
  151.    devices = (cl_device_id *)malloc(deviceListSize);
  152.    if(devices == 0)
  153.    {
  154.        std::cout<<"Error: No devices found.\n";
  155.        return 1;
  156.    }
  157.  
  158.    /* Now, get the device list data */
  159.    status = clGetContextInfo(
  160.                 context,
  161.                 CL_CONTEXT_DEVICES,
  162.                 deviceListSize,
  163.                 devices,
  164.                 NULL);
  165.    if(status != CL_SUCCESS)
  166.    {
  167.        std::cout<<
  168.            "Error: Getting Context Info \
  169.            (device list, clGetContextInfo)\n";
  170.        return 1;
  171.    }
  172.  
  173.    /////////////////////////////////////////////////////////////////
  174.    // Create an OpenCL command queue
  175.    /////////////////////////////////////////////////////////////////
  176.    commandQueue = clCreateCommandQueue(
  177.                       context,
  178.                       devices[0],
  179.                       0,
  180.                       &status);
  181.    if(status != CL_SUCCESS)
  182.    {
  183.        std::cout<<"Creating Command Queue. (clCreateCommandQueue)\n";
  184.        return 1;
  185.    }
  186.  
  187.    /////////////////////////////////////////////////////////////////
  188.    // Create OpenCL memory buffers
  189.    /////////////////////////////////////////////////////////////////
  190.  
  191.    outputBuffer = clCreateBuffer(
  192.                       context,
  193.                       CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
  194.                       sizeof(cl_uint) * width,
  195.                       output,
  196.                       &status);
  197.    if(status != CL_SUCCESS)
  198.    {
  199.        std::cout<<"Error: clCreateBuffer (outputBuffer)\n";
  200.        return 1;
  201.    }
  202.  
  203.  
  204.    /////////////////////////////////////////////////////////////////
  205.    // Load CL file, build CL program object, create CL kernel object
  206.    /////////////////////////////////////////////////////////////////
  207.    const char * filename  = "kernel.cl";
  208.    std::string  sourceStr = convertToString(filename);
  209.    const char * source    = sourceStr.c_str();
  210.    size_t sourceSize[]    = { strlen(source) };
  211.  
  212.    program = clCreateProgramWithSource(
  213.                  context,
  214.                  1,
  215.                  &source,
  216.                  sourceSize,
  217.                  &status);
  218.    if(status != CL_SUCCESS)
  219.    {
  220.      std::cout<<
  221.               "Error: Loading Binary into cl_program \
  222.               (clCreateProgramWithBinary)\n";
  223.      return 1;
  224.    }
  225.  
  226.    /* create a cl program executable for all the devices specified */
  227.    status = clBuildProgram(program, 1, devices, NULL, NULL, NULL);
  228.    if(status != CL_SUCCESS)
  229.    {
  230.        std::cout<<"Error: Building Program (clBuildProgram)\n";
  231.        return 1;
  232.    }
  233.  
  234.    /* get a kernel object handle for a kernel with the given name */
  235.    kernel = clCreateKernel(program, "Prime", &status);
  236.    if(status != CL_SUCCESS)
  237.    {
  238.        std::cout<<"Error: Creating Kernel from program. (clCreateKernel)\n";
  239.        return 1;
  240.    }
  241.  
  242.    return 0;
  243. }
  244.  
  245.  
  246. /*
  247.  * \brief Run OpenCL program
  248.  *
  249.  *        Bind host variables to kernel arguments
  250.  *          Run the CL kernel
  251.  */
  252. int
  253. runCLKernels(void)
  254. {
  255.    cl_int   status;
  256.    cl_uint maxDims;
  257.    cl_event events[2];
  258.     size_t maxWorkGroupSize;
  259.    size_t maxWorkItemSizes[3];
  260.  
  261.    /**
  262.     * Query device capabilities. Maximum
  263.     * work item dimensions and the maximmum
  264.     * work item sizes
  265.     */
  266.    status = clGetDeviceInfo(
  267.        devices[0],
  268.        CL_DEVICE_MAX_WORK_GROUP_SIZE,
  269.        sizeof(size_t),
  270.        (void*)&maxWorkGroupSize,
  271.        NULL);
  272.    if(status != CL_SUCCESS)
  273.    {
  274.        std::cout<<"Error: Getting Device Info. (clGetDeviceInfo)\n";
  275.        return 1;
  276.    }
  277.  
  278.    status = clGetDeviceInfo(
  279.        devices[0],
  280.        CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
  281.        sizeof(cl_uint),
  282.        (void*)&maxDims,
  283.        NULL);
  284.    if(status != CL_SUCCESS)
  285.    {
  286.        std::cout<<"Error: Getting Device Info. (clGetDeviceInfo)\n";
  287.        return 1;
  288.    }
  289.  
  290.    status = clGetDeviceInfo(
  291.        devices[0],
  292.        CL_DEVICE_MAX_WORK_ITEM_SIZES,
  293.        sizeof(size_t)*maxDims,
  294.        (void*)maxWorkItemSizes,
  295.        NULL);
  296.    if(status != CL_SUCCESS)
  297.    {
  298.        std::cout<<"Error: Getting Device Info. (clGetDeviceInfo)\n";
  299.        return 1;
  300.    }
  301.  
  302.    /*** Set appropriate arguments to the kernel ***/
  303.    /* the output array to the kernel */
  304.    status = clSetKernelArg(
  305.                    kernel,
  306.                    0,
  307.                    sizeof(cl_mem),
  308.                    (void *)&outputBuffer);
  309.    if(status != CL_SUCCESS)
  310.    {
  311.        std::cout<<"Error: Setting kernel argument. (output)\n";
  312.        return 1;
  313.    }
  314.    status = clGetKernelWorkGroupInfo(kernel,
  315.        devices[0],
  316.        CL_KERNEL_LOCAL_MEM_SIZE,
  317.        sizeof(cl_ulong),
  318.        &usedLocalMemory,
  319.        NULL);
  320.    if(status != CL_SUCCESS)
  321.    {
  322.        std::cout<<"clGetKernelWorkGroupInfo CL_KERNEL_LOCAL_MEM_SIZE failed." << std::endl;
  323.        return 1;
  324.    }
  325.  
  326.    if(usedLocalMemory > totalLocalMemory)
  327.    {
  328.        std::cout << "Unsupported: Insufficient local memory on device" << std::endl;
  329.        return 1;
  330.    }
  331.  
  332.    /* Check group size against group size returned by kernel */
  333.    status = clGetKernelWorkGroupInfo(kernel,
  334.        devices[0],
  335.        CL_KERNEL_WORK_GROUP_SIZE,
  336.        sizeof(size_t),
  337.        &kernelWorkGroupSize,
  338.        0);
  339.    if(status != CL_SUCCESS)
  340.    {
  341.        std::cout<<"clGetKernelWorkGroupInfo CL_KERNEL_COMPILE_WORK_GROUP_SIZE failed." << std::endl;
  342.        return 1;
  343.    }
  344.  
  345.    if(groupSize > kernelWorkGroupSize)
  346.    {
  347.        std::cout << "Out of Resources!" << std::endl;
  348.        std::cout << "Group Size specified : " << groupSize << std::endl;
  349.        std::cout << "Max Group Size supported on the kernel : " << kernelWorkGroupSize << std::endl;
  350.        std::cout << "Falling back to " << kernelWorkGroupSize << std::endl;
  351.        groupSize = kernelWorkGroupSize;
  352.    }
  353.    /*
  354.      * Enqueue a kernel run call.
  355.      */
  356.    size_t globalThreads[] = {width};
  357.    size_t localThreads[] = {1};
  358.    if(localThreads[0] > maxWorkItemSizes[0] ||
  359.       localThreads[0] > maxWorkGroupSize)
  360.    {
  361.        std::cout << "Unsupported: Device" "does not support requested number of work items.";
  362.        return 1;
  363.    }
  364.    status = clEnqueueNDRangeKernel(
  365.                 commandQueue,
  366.                 kernel,
  367.                 1,
  368.                 NULL,
  369.                 globalThreads,
  370.                 localThreads,
  371.                 0,
  372.                 NULL,
  373.                 &events[0]);
  374.    if(status != CL_SUCCESS)
  375.    {
  376.        std::cout<<
  377.            "Error: Enqueueing kernel onto command queue. \
  378.            (clEnqueueNDRangeKernel)\n";
  379.        return 1;
  380.    }
  381.  
  382.  
  383.    /* wait for the kernel call to finish execution */
  384.    status = clWaitForEvents(1, &events[0]);
  385.    if(status != CL_SUCCESS)
  386.    {
  387.        std::cout<<
  388.            "Error: Waiting for kernel run to finish. \
  389.            (clWaitForEvents)\n";
  390.        return 1;
  391.    }
  392.  
  393.    status = clReleaseEvent(events[0]);
  394.    if(status != CL_SUCCESS)
  395.    {
  396.        std::cout<<
  397.            "Error: Release event object. \
  398.            (clReleaseEvent)\n";
  399.        return 1;
  400.    }
  401.  
  402.    /* Enqueue readBuffer*/
  403.    status = clEnqueueReadBuffer(
  404.                commandQueue,
  405.                outputBuffer,
  406.                CL_TRUE,
  407.                0,
  408.                width * sizeof(cl_uint),
  409.                output,
  410.                0,
  411.                NULL,
  412.                &events[1]);
  413.  
  414.    if(status != CL_SUCCESS)
  415.    {
  416.        std::cout <<
  417.            "Error: clEnqueueReadBuffer failed. \
  418.             (clEnqueueReadBuffer)\n";
  419.  
  420.        return 1;
  421.    }
  422.  
  423.    /* Wait for the read buffer to finish execution */
  424.    status = clWaitForEvents(1, &events[1]);
  425.    if(status != CL_SUCCESS)
  426.    {
  427.        std::cout<<
  428.            "Error: Waiting for read buffer call to finish. \
  429.            (clWaitForEvents)\n";
  430.        return 1;
  431.    }
  432.  
  433.    status = clReleaseEvent(events[1]);
  434.    if(status != CL_SUCCESS)
  435.    {
  436.        std::cout<<
  437.            "Error: Release event object. \
  438.            (clReleaseEvent)\n";
  439.        return 1;
  440.    }
  441.  
  442.    return 0;
  443. }
  444.  
  445.  
  446. /*
  447.  * \brief Release OpenCL resources (Context, Memory etc.)
  448.  */
  449. int
  450. cleanupCL(void)
  451. {
  452.    cl_int status;
  453.  
  454.    status = clReleaseKernel(kernel);
  455.    if(status != CL_SUCCESS)
  456.    {
  457.        std::cout<<"Error: In clReleaseKernel \n";
  458.        return 1;
  459.    }
  460.    status = clReleaseProgram(program);
  461.    if(status != CL_SUCCESS)
  462.    {
  463.        std::cout<<"Error: In clReleaseProgram\n";
  464.        return 1;
  465.    }
  466.    status = clReleaseMemObject(outputBuffer);
  467.    if(status != CL_SUCCESS)
  468.    {
  469.        std::cout<<"Error: In clReleaseMemObject (outputBuffer)\n";
  470.        return 1;
  471.    }
  472.    status = clReleaseCommandQueue(commandQueue);
  473.    if(status != CL_SUCCESS)
  474.    {
  475.        std::cout<<"Error: In clReleaseCommandQueue\n";
  476.        return 1;
  477.    }
  478.    status = clReleaseContext(context);
  479.    if(status != CL_SUCCESS)
  480.    {
  481.        std::cout<<"Error: In clReleaseContext\n";
  482.        return 1;
  483.    }
  484.  
  485.    return 0;
  486. }
  487.  
  488.  
  489. /*
  490.  * \brief Releases program's resources
  491.  */
  492. void
  493. cleanupHost(void)
  494. {
  495.    if(output != NULL)
  496.    {
  497.        free(output);
  498.        output = NULL;
  499.    }
  500.    if(devices != NULL)
  501.    {
  502.        free(devices);
  503.        devices = NULL;
  504.    }
  505. }
  506.  
  507.  
  508.  
  509. int
  510. main(int argc, char * argv[])
  511. {
  512.    bool GPU = true;
  513.    for(int i = 0; i < 2; i++)
  514.    {
  515.    // Initialize Host application
  516.    if(initializeHost()==1)
  517.        return 1;
  518.  
  519.    // Initialize OpenCL resources
  520.    if(initializeCL(GPU)==1)
  521.    return 1;
  522. /*  char C;
  523.     do
  524.     {
  525.         std::cout << "Use GPU?(Y/N)" << std::endl;
  526.         C = getch();
  527.     }while(!((C == 'Y') || (C == 'y') || (C == 'n') || (C == 'N')));
  528.     if(C == 'Y' || C == 'y')
  529.     {
  530.         if(initializeCL(true)==1)
  531.             return 1;
  532.     }
  533.     else
  534.     {
  535.         if(initializeCL(false)==1)
  536.             return 1;
  537.     }*/
  538.  
  539.    // Run the CL program
  540.    float Clocklast = clock();
  541.    if(runCLKernels()==1)
  542.        return 1;
  543.    float Benchtime = (clock() - Clocklast) / CLOCKS_PER_SEC;
  544.    // Print output array
  545.    //for(int i = 0; i < width; i++) std::cout << output[i] << " ";
  546.    if(GPU) std::cout << "With GPU: "; else std::cout << "With CPU: ";
  547.    std::cout << Benchtime << " Seconds" << std::endl;
  548.        // Releases OpenCL resources
  549.    if(cleanupCL()==1)
  550.        return 1;
  551.  
  552.    // Release host resources
  553.    cleanupHost();
  554.    GPU = false;
  555.    }
  556.    return 0;
  557. }
  558.  
  559.  

Main.hpp:

Código
  1. #include <CL/cl.h>
  2. #include <string.h>
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <time.h>
  6. #include <fstream>
  7. #include <conio.h>
  8. /*** GLOBALS ***/
  9.  
  10. cl_uint *output;
  11. cl_ulong totalLocalMemory;
  12. cl_ulong usedLocalMemory;
  13. size_t kernelWorkGroupSize;
  14. size_t groupSize;
  15. cl_uint width;
  16.  
  17. /* The memory buffer that is used as input/output for OpenCL kernel */
  18. cl_mem     outputBuffer;
  19.  
  20. cl_context          context;
  21. cl_device_id        *devices;
  22. cl_command_queue    commandQueue;
  23.  
  24. cl_program program;
  25.  
  26. /* This program uses only one kernel and this serves as a handle to it */
  27. cl_kernel  kernel;
  28.  
  29.  
  30. /*** FUNCTION DECLARATIONS ***/
  31. /*
  32.  * OpenCL related initialisations are done here.
  33.  * Context, Device list, Command Queue are set up.
  34.  * Calls are made to set up OpenCL memory buffers that this program uses
  35.  * and to load the programs into memory and get kernel handles.
  36.  */
  37. int initializeCL(bool UseGPU);
  38.  
  39. /*
  40.  *
  41.  */
  42. std::string convertToString(const char * filename);
  43.  
  44. /*
  45.  * This is called once the OpenCL context, memory etc. are set up,
  46.  * the program is loaded into memory and the kernel handles are ready.
  47.  *
  48.  * It sets the values for kernels' arguments and enqueues calls to the kernels
  49.  * on to the command queue and waits till the calls have finished execution.
  50.  *
  51.  * It also gets kernel start and end time if profiling is enabled.
  52.  */
  53. int runCLKernels(void);
  54.  
  55. /* Releases OpenCL resources (Context, Memory etc.) */
  56. int cleanupCL(void);
  57.  
  58. /* Releases program's resources */
  59. void cleanupHost(void);
  60. /*
  61.  * Prints no more than 256 elements of the given array.
  62.  * Prints full array if length is less than 256.
  63.  *
  64.  * Prints Array name followed by elements.
  65.  */
  66. void print1DArray(
  67.         const std::string arrayName,
  68.         const unsigned long * arrayData,
  69.         const unsigned int length);
  70.  

Kernel.cl

Código
  1. __kernel
  2. void Prime(
  3.    __global unsigned int * output)
  4. {
  5. uint tid = get_global_id(0);
  6. output[tid] = 2 * tid;
  7. }
  8.  

El kernel es muy simple, iba a calcular primos, por eso se llama "prime" pero bueno, todavía no me puse a hacerlo.

Un abrazo
APOKLIPTICO
69  Programación / Programación C/C++ / malloc_align y free_align. en: 16 Septiembre 2010, 18:26 pm
Hola gente, como va todo?
Estoy jugando un poco con la tecnología opencl y atistream, y entonces, me puse a tratar de adaptar un sample de Nbody, muy interesante que viene con el SDK a mi IDE code::blocks + Mingw. Pero me encontré con algunos problemas, cuando pude resolver todos los problemas del linker, me encontré con estos pedazos de código:
Código
  1. #if defined (_WIN32)
  2.    pos = (cl_float*)malloc_align(numBodies * sizeof(cl_float4),16);
  3. #else
  4.    pos = (cl_float*)memalign(16, numBodies * sizeof(cl_float4));
  5. #endif

y
Código
  1. #if defined (_WIN32)
  2.       free_align (pos);
  3. #else
  4.        free(pos);
  5. #endif

No pude encontrar los includes que funcionan con codeblocks + mingw, entonces pensé si era posible usar los operadores "new" y "delete" para allocar la memoria. Pero despues de probar varias formas, decidí pedir ayuda.
Alguien sabe cual es el include que funciona con esto, o como adaptarlo para que funcione con "new" y "delete"??
Muchas gracias!
70  Informática / Hardware / Artifacts y overclocking nforce 410. en: 9 Septiembre 2010, 23:14 pm
Hola gente, como va todo? Bueno hoy traigo dos preguntas:
1) Hay algún buen programa que tenga la opción de "scan for artifacts" como hacía el ATI TOOL, pero que ande? (aclaro: el ati tool no me anda). Es que quiero overclockear mi ATI HD 4850 pero no quiero tener que ponerme a jugar cada vez que hago un cambio para ver si salen artifacts.

2) Hay alguna manera de overclockear mi micro Sempron 2500+ con un chipset nforce 410/430mcp. Aclaro:
- No me anda Ntune/Nvidia system settings. Dejó de funcionar hace un tiempo y no se como puedo llegar a hacerlo funcionar (ni siquiera los de nvidia saben aparentemente). El problema en cuestión es que el slider para modificar el bus, me aparece con rangos ridículos (de 0 Mhz a 20 Mhz), al poner "apply" me tira un error "FSB Bus modification: error. Se han restablecido los valores". Tampoco funciona ejecutando los archivitos .nsu.
- No me anda el clockgen, cuando hago click en apply, me hace toda la pantomima como si los hubiese aplicado, pero no lo hace.
- Ni el SetFSB, aparentemente no tiene soporte para nforce 410.
- Tampoco el CPUCOOL/CPUFSB.
- Lo único que puedo modificar por bios es el Vdimm y los timings (el primero no me sirve demasiado y el segundo lo puedo modificar con memset).

Alguien sabe algo?
Gracias!
Un abrazo
APOKLIPTICO
Páginas: 1 2 3 4 5 6 [7] 8 9 10 11 12
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines