From owner-freebsd-ppc@freebsd.org Thu Jun 9 15:47:33 2016 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0DBCAEFE47 for ; Thu, 9 Jun 2016 15:47:33 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-it0-x232.google.com (mail-it0-x232.google.com [IPv6:2607:f8b0:4001:c0b::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB4031EDA for ; Thu, 9 Jun 2016 15:47:33 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-it0-x232.google.com with SMTP id a5so41034080ita.1 for ; Thu, 09 Jun 2016 08:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=cc:message-id:from:to:in-reply-to:content-transfer-encoding :mime-version:subject:date:references; bh=huL4xRLXkI2qrX4Gu50yuDuVqJV+yOaYAwmCz55ghRw=; b=AV3TMUMjMgxGfLR7lntS5v2xLWKRF0mfGYN2OV08IPAt+gfr0T/x2vIC95wSz6EJ5Z rgxso9SaZZ9uHjrMgXwXYMGykU9TpUgNCm52BcM7KfZYObaCi5t6oLrlATk4bvV39IOU iqVeo0G/K1zvIet+jAKXe29A/I5GROvGoird12yOEd4e95hNtrqDYUCUzlc2pG0aFgVO 5r1s4b5JrsOvwTd4b7P2YuE2qmwzWGEZkKIZg8A5fwICWvqYhFHPauDLfgfdHpirn1I1 MbLhx9PI0+oWJpIEn67IelJxfnnvu/eaLRz1BaZ3iV5zgkMC76fDCytDiKM6ER1U7rba heHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:cc:message-id:from:to:in-reply-to :content-transfer-encoding:mime-version:subject:date:references; bh=huL4xRLXkI2qrX4Gu50yuDuVqJV+yOaYAwmCz55ghRw=; b=KezG1e8XayfF2Qwpo9VDYZ2mJXJrP5Bz8nSlrC2ffzzr5TmJWsZJlKnLI2TlxqBh00 jZ49qU2y6DLN6KZkgpxqMOeWytNevIUD8wNel0i5jBNUTp65+bH4lNPscm+WBqrFZXiM C6TgqrKjtNkDqbS//GjOj5liWom6TK1wJ2pVz4//wISQv4RrDaSPgClpXEkeSapABgRb smbwJwrfybxgcck6ZtMZjCpSG1Jgxyrcvp+YOqlSeN/n/i3eeuj5JLehW8A6GQaUe5wd 1puR+3sdzoHzQbt66u45wBP+O9Em9aIW2+9racXFrudSB9FlCeSsEM2rRukxnHjZ6Z+0 vr5A== X-Gm-Message-State: ALyK8tLI+p/2oLa4LfH96k1pKxyJ72TOQtu+CVvdDE7R7TwUXkJxVYIrVVFoaUvIuzadEg== X-Received: by 10.36.11.84 with SMTP id 81mr18527629itd.89.1465487252986; Thu, 09 Jun 2016 08:47:32 -0700 (PDT) Received: from [10.65.211.198] ([137.122.64.8]) by smtp.gmail.com with ESMTPSA id u21sm19871377itc.1.2016.06.09.08.47.30 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Jun 2016 08:47:32 -0700 (PDT) Cc: "freebsd-ppc@freebsd.org" Message-Id: <3FD85BCC-4304-4DBA-8B72-5A6A79C120A6@gmail.com> From: Justin Hibbits To: Jason Bacon In-Reply-To: <765d3292-78ae-8b02-8a5b-43bafc68d9e8@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Detecting Power7 in C Date: Thu, 9 Jun 2016 11:47:29 -0400 References: <765d3292-78ae-8b02-8a5b-43bafc68d9e8@gmail.com> X-Mailer: Apple Mail (2.936) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2016 15:47:34 -0000 On Jun 9, 2016, at 9:09 AM, Jason Bacon wrote: > > I'm porting the SLURM task/affinity plugin to FreeBSD and wondering > what's the best way to detect whether we're running on a power7 > processor. > > The Linux code is below. I could do something similar with > dmesg.boot on FreeBSD, but hoping there's a more elegant way within > a C program. > > If I have to use dmesg.boot, what string would I be looking for? I > don't have a power7 installation at the moment. > > Thanks, > > Jason > > FILE *cpu_info_file; > > char buffer[128]; > char* _cpuinfo_path = "/proc/cpuinfo"; > cpu_info_file = fopen(_cpuinfo_path, "r"); > if (cpu_info_file == NULL) { > error("_get_is_power: error %d opening %s", > errno, > _cpuinfo_path); > return false; /* assume not power processor > */ > } > > is_power = 0; > while (fgets(buffer, sizeof(buffer), cpu_info_file) ! > = NULL) { > if (strstr(buffer, "POWER7")) { > is_power = 1; > break; > } > } > fclose(cpu_info_file); You can use the hw.model sysctl. For POWER7, the string you would receive is "POWER7". For all the model strings you can get, see the strings in the models[] table in sys/powerpc/powerpc/cpu.c . - Justin