Hi all, I'm writing an opencl kernel to find maximal cliques. The kernel
selects a node by the thread gid and finds the max subgraph containing that
node. Unfortunately, around 10000 nodes, I get an out of memory error. The
program is for one of my math professors and tests a conjecture of his, so
I can't post the code in it's entirety, but I'll give a simplified example.

I've tried cutting down the size of the static arrays in the functions that
have them. Is there anything else I can do other than get a card with more
memory?

Thanks for your time,
Tyler

#!/usr/bin/python2.7

import pyopencl as cl
import numpy

def max_clique(nodes_list, resid_list):
    resid_list.append(0)

    num_nodes = numpy.int32(len(nodes_list))
    num_resid = numpy.int32(len(resid_list))

    nodes_arr = numpy.array(nodes_list, dtype='i4')
    resid_arr = numpy.array(resid_list, dtype='i4')

    ctx = cl.create_some_context()
    queue = cl.CommandQueue(ctx)

    mf = cl.mem_flags
    nodes_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR,
hostbuf=nodes_arr)
    resid_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR,
hostbuf=resid_arr)
    dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY, nodes_arr.nbytes)

    prg = cl.Program(ctx, """
        bool adj(int node1, int node2, __global int *adj)
        {
            // are node1 and node2 adjacent?
        }

        // checks if node is adj to all nodes in chain
        bool adj_all(int* nodes, int* G, int chain_len, int node, __global
int* adj){
            // is node adjacent to to all nodes in G?
        }

        #define MAX_NODES 64
        int chain(int num_nodes, int* nodes, __global int* connect)
        {
            int cur[MAX_NODES];

            // Find max clique in G
        }

        __kernel void max_clique(__global int *nodes,
                                            __global int *resid,
                                            __global int *out,
                                            int num_nodes,
                                            int num_resid)
        {
            int gid = get_global_id(0);
            int G[constant];
            // find subgraph around nodes[gid], we call it G, store
            // it's nodes in G
            out[gid] = // max clique of G;
        }
        """).build()

    prg.max_clique(queue, nodes_arr.shape, None, nodes_buf,
                                                    resid_buf,
                                                    dest_buf,
                                                    num_nodes,
                                                    num_resid)
    cliques = numpy.empty_like(nodes_arr)
    cl.enqueue_copy(queue, cliques, dest_buf)
    return max(cliques)

print max_clique(range(0, 10000), range(1, 10))
_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to